-1

platform: ubuntu 22.04

I am performing advance routing and and I have saved all the commands in the /etc/rc.local file. the problem is once the systemd-networkd.service is restarted, the routing table is going to be flushed and my routing including the static routes are removed and bring down the server connectivity.

is there any way to instruct the systemd-networkd.service to run the /etc/rc.local once it is being restarted? I'm using default netplan config.

the systemd-networkd.service is being restarted once the packages are being upgraded.

Regards,

5
  • Since there are some major differences between Ubuntu 22.04 and 24.04 please pick one you want an answer for. The answer may be different for each.
    – David
    Commented Jun 18 at 17:55
  • eh you should have a rc-local.service. why not add that to the systemd chain?
    – Rinzwind
    Commented Jun 18 at 18:20
  • @David lets go with 22.04
    – Behzad
    Commented Jun 18 at 22:41
  • @Rinzwind i have created the systemd chain to run after the systemd-networkd service restart. though, it seems that it qas not working
    – Behzad
    Commented Jun 18 at 22:42
  • Do not tell me edit the question please.
    – David
    Commented Jun 19 at 5:56

1 Answer 1

0

I believe I've found the solution: here it is:

mkdir -p /etc/systemd/system/systemd-networkd.service.d
vi /etc/systemd/system/systemd-networkd.service.d/override.conf
[Service]
ExecStartPost=/etc/rc.local
systemctl daemon-reload

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .