I have an issue with network configuration in ubuntu server 18.04. My host does not apply default gateway route from dhcp server.

My netplan config is:

version: 2
       addresses: []
       dhcp4: true
       optional: true

ip route: via dev enp0s8 proto dhcp metric 100 via dev enp0s8 proto dhcp metric 100 via dev enp0s8 proto dhcp metric 100 dev enp0s8 proto kernel scope link src

netplan ip leases enp0s8:


I also tried to add gateway4 option into netplan config - it has no effect.

But if I manually add route to default gw - everything starts to work fine.

  • Could you please provide the result of command sudo dhclient <INT> -v (manually search for a DHCP IP/GW). – Eraseth Nov 20 '18 at 14:05
  • Maybe you need to specify the "renderer". Currently, netplan support NetworkManager or Systemd-networkd. – Eraseth Nov 20 '18 at 14:23
  • I have the same problem as you it seems – Christopher Perrin Nov 23 '18 at 8:57
  • Why are you specifying 'addresses: []' which should be the default? Does removing this line change the behavior? – slangasek Dec 5 '18 at 9:35
  • Same problem here. Did you ever find out why this happens? – taalas Jan 11 '19 at 7:03

The issue is, that DHCP is setting rules for static routes (dhcp option 121) and in such a case the router gateway is disregarded as explained here

You can see from what netplan ip leases returns on the second to last line, the DHCP rules are setting static routes.

One option seems to work in Ubuntu 16, by adding another routing rule for as explained in the answer by @greecemonkey (although I have not tried that and cannot confirm if it would work in netplan on Ubuntu 18)

The other answer given involves ignoring the static routes provided by the DHCP server as explained in the answer given by @Flash5k. Unfortunately this does not work in netplan on Ubuntu 18.04. Editing the /etc/dhcpcd.conf file has no affect, as netplan is not using this file (it uses an internal dhcp client).

In newer versions of netplan they have a new option for dhcp-overrides that allows one to ignore the routes provided by the DHCP server (as well as other setting provided by DHCP). Unfortunately as of now this has not been back ported to Ubuntu 18.04.

| improve this answer | |

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.