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.

  • Juntti@sopuli.xyzOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 days ago

    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.

    • lemmy_user_838586@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      2 days ago

      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.”

      • Juntti@sopuli.xyzOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 day 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.