1

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:

network:
version: 2
ethernets:
    enp0s8:
       addresses: []
       dhcp4: true
       optional: true

ip route:

172.16.0.0/22 via 192.168.26.1 dev enp0s8 proto dhcp metric 100 
172.20.0.0/24 via 192.168.26.1 dev enp0s8 proto dhcp metric 100 
192.168.0.0/16 via 192.168.26.1 dev enp0s8 proto dhcp metric 100 
192.168.26.0/24 dev enp0s8 proto kernel scope link src 192.168.26.227

netplan ip leases enp0s8:

ADDRESS=192.168.26.227
NETMASK=255.255.255.0
ROUTER=192.168.26.1
SERVER_ADDRESS=172.16.0.100
NEXT_SERVER=172.16.0.100
T1=1000000
T2=1750000
LIFETIME=2000000
DNS=172.16.0.250 172.16.0.100
NTP=172.16.0.1
DOMAINNAME=domain.name
ROUTES=172.20.0.0/24,192.168.26.1 172.16.0.0/22,192.168.26.1 192.168.0.0/16,192.168.26.1
CLIENTID=ffaf818f7d00020000ab11546f22c88c98f9a0

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
1

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