this post was submitted on 24 Apr 2025
9 points (100.0% liked)

Linux

10075 readers
269 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 2 years ago
MODERATORS
 

OS: Ubuntu 24.04

I have searched this for a while and seems i can't get my search terms right.

Back when ifuo/down system worked custom scripts were put under '/etc/network/if-up.d' etc. Now ubuntu uses netplan. But where to put custom script? That would handle tc rules in my case. /etc/networkd-dispatcher/routable.d was told by internet but that just trows error during boot; ERROR:Unknown state for interface.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 6 days ago (3 children)

Disclaimer, I'm not in front of my computer to check, but it looks like its /etc/netplan/

https://netplan.readthedocs.io/en/stable/netplan-tutorial/

[–] [email protected] 1 points 6 days ago (2 children)

Looked url, searched 'custom' and 'script' (page and site) with no match that im looking for. All i know now and looking more around; netplan way to use custom script when interface comes up is networkd-dispatcher way, that in Ubuntu 24.04 do not work.

[–] [email protected] 2 points 4 days ago* (last edited 4 days ago) (1 children)

Ahh I see, I didn't know what tc was and assumed it was a typo and ignored it. I searched for a bit for your specific problem and didn't come up with much other than this:

You could also try

/usr/lib/networkd-dispatcher/routable.d/

Looks like you can also specify the scripts directoy with -S flag

https://manpages.ubuntu.com/manpages/noble/en/man8/networkd-dispatcher.8.html

My other thought is: maybe the location for the scripts is correct, but you're having another issue thats causing the unknown state error?

You might also want to make sure all the required environment variables are set correctly?

Per the man page:

"Scripts are executed with some environment variables set."

[–] [email protected] 1 points 4 days ago

'journalctl -u networkd-dispatcher' says:

systemd[1]: Starting networkd-dispatcher.service - Dispatcher daemon for systemd-networkd...
networkctl[2463]: systemd-networkd is not running, output might be incomplete.`
systemd[1]: networkd-dispatcher.service: Got notification message from PID 2463, but reception only permitted for main PID 2242
networkd-dispatcher[2242]: ERROR:Unknown state for interface NetworkctlListState(idx=1, name='lo', type='loopback', operational='-', administrative='unmanaged'): -
networkd-dispatcher[2242]: Traceback (most recent call last):
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 299, in trigger_all
networkd-dispatcher[2242]:     self.handle_state(iface_name,
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 349, in handle_state
networkd-dispatcher[2242]:     raise UnknownState(operational_state)
networkd-dispatcher[2242]: UnknownState: -
networkd-dispatcher[2242]: ERROR:Unknown state for interface NetworkctlListState(idx=2, name='enp3s0', type='ether', operational='-', administrative='unmanaged'): -
networkd-dispatcher[2242]: Traceback (most recent call last):
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 299, in trigger_all
networkd-dispatcher[2242]:     self.handle_state(iface_name,
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 349, in handle_state
networkd-dispatcher[2242]:     raise UnknownState(operational_state)
networkd-dispatcher[2242]: UnknownState: -
networkd-dispatcher[2242]: ERROR:Unknown state for interface NetworkctlListState(idx=3, name='wlp0s20f3', type='wlan', operational='-', administrative='unmanaged'): -
networkd-dispatcher[2242]: Traceback (most recent call last):
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 299, in trigger_all
networkd-dispatcher[2242]:     self.handle_state(iface_name,
networkd-dispatcher[2242]:   File "/usr/bin/networkd-dispatcher", line 349, in handle_state
networkd-dispatcher[2242]:     raise UnknownState(operational_state)
networkd-dispatcher[2242]: UnknownState: -

That error comes either I have my script there or not.

I think scripts in '/etc/networkd-dispatcher/routable.d' or '/usr/lib/networkd-dispatcher/routable.d' are not ran because networkd-dispatched do not get interface state.

Based on https://netplan.io/faq > 'Use pre-up, post-up, etc. hook scripts'; routable.d is correct location in my case.