I have running an Ubuntu 18.04 with 2 ethernet NICs. On both NICs I'm using DHCP. How can I prevent netplan from creating a default route to on both devices? I want one NIC routing to and the other one in a specific /24 subnet via a gateway. I know that I can add a route in the netplan config but it will always create the default route to

  • Welcome to Unix & Linux! :-) Go static on both adapters or static on at least one of the adapters. Going DHCP on both is a bad idea as you found out. – Fabby May 9 at 14:10
  • Network Manager has a specific option to ignore the default route on DHCP. No idea about netplan. Just telling some people thought about this issue, even for DHCP – A.B Jun 3 at 0:43

For more control of your NICs, go static on both adapters or static on at least one of the adapters.

This can be easily done in that specific range by reserving both IPs for their respective MAC addresses in their respective DHCP servers and then you will not have any of the limitations of DHCP and configure everything or part manually.

(E.G. If your corporate policy would require you to use a totally different IP range if using static, you can still use the aforementioned hybrid technology)


According to this answer, it should be possible with dhcp4-overrides, however that is not supported in Ubuntu as of 18.04. My workaround was to create a hook script in /etc/networkd-dispatcher/routable.d/ to remove the default route:


# Only remove the default route on the second interface, e.g. eth1
[ "$IFACE" != eth1 ] && exit 0

# delete the default route for this interface
ip route del default dev eth1

Make sure the file owner and group are root and that it is executable.

You can find out more about networkd-dispatcher here: https://gitlab.com/craftyguy/networkd-dispatcher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.