Public bug reported: >From <https://askubuntu.com/questions/1054572/netplan-is-there-an- equivalent-to-post-up>, a user wants to add a static route to a network interface where the gateway is known, but the interface's local address is configured via dhcp.
This doesn't work with direct netplan yaml, because networkd will try to apply the static routes before the interface has been configured via dhcp, failing because there is not yet a route to the gateway on that interface. Demonstrating in a lxd container locally, which has 10.44.49.0/24 as its network: $ cat /etc/netplan/50-cloud-init.yaml # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: eth0: dhcp4: true routes: - to: 10.44.48.0/24 via: 10.44.49.2 metric: 10 $ systemctl status systemd-networkd --no-pager -l ● systemd-networkd.service - Network Service Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2018-07-13 19:21:29 UTC; 8min ago Docs: man:systemd-networkd.service(8) Main PID: 165 (systemd-network) Status: "Processing requests..." Tasks: 1 (limit: 4915) CGroup: /system.slice/systemd-networkd.service └─165 /lib/systemd/systemd-networkd Jul 13 19:21:29 stable-dane systemd[1]: Starting Network Service... Jul 13 19:21:29 stable-dane systemd-networkd[165]: Enumeration completed Jul 13 19:21:29 stable-dane systemd[1]: Started Network Service. Jul 13 19:21:29 stable-dane systemd-networkd[165]: eth0: Could not set route: Network is unreachable Jul 13 19:21:29 stable-dane systemd-networkd[165]: eth0: DHCPv4 address 10.44.49.32/24 via 10.44.49.1 Jul 13 19:21:29 stable-dane systemd-networkd[165]: Not connected to system bus, not setting hostname. Jul 13 19:21:29 stable-dane systemd-networkd[165]: eth0: Gained IPv6LL Jul 13 19:21:29 stable-dane systemd-networkd[165]: eth0: Configured Jul 13 19:21:55 stable-dane systemd-networkd[165]: Could not set hostname: Method call timed out $ ip route default via 10.44.49.1 dev eth0 proto dhcp src 10.44.49.32 metric 100 10.44.49.0/24 dev eth0 proto kernel scope link src 10.44.49.32 10.44.49.1 dev eth0 proto dhcp scope link src 10.44.49.32 metric 100 $ netplan and networkd should DTRT. ** Affects: netplan Importance: Low Status: New ** Affects: systemd (Ubuntu) Importance: Undecided Status: New ** Changed in: netplan Importance: Undecided => Low ** Also affects: systemd (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1781652 Title: should be possible to specify static routes on a dhcp-configured interface To manage notifications about this bug go to: https://bugs.launchpad.net/netplan/+bug/1781652/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs