DHCP connection does not set default gateway automatically

I'm experiencing the same issue on Ubuntu Server 16.04. After troubleshooting, my issue stems from my DHCP server also providing a Classless Static Route (DHCP option 121, rfc3442-classless-static-routes in ISC DHCP), from a Microsoft DHCP server (Windows Server 2008 R2).

Looking at /sbin/dhclient-script, if at least one classless static route is provided to the DHCP client, it disregards the router setting, hence no default route set.

# if we have $new_rfc3442_classless_static_routes then we have to
# ignore $new_routers entirely

My "fix" is to add another classless static route to the Windows DHCP server. So:

  • Destination: 0.0.0.0
  • Network Mask: 0.0.0.0
  • Router: 192.168.1.1

(once added, the Network Mask is automagically changed to 255.255.255.255)

I do have short DHCP lease expiry (15 minutes) and have not had any complaints from other Linux or Windows users on the network since adding the new route, so I figure the change should not cause major issues.

As I'm too new to comment:

  • @t11z My lease file is /var/lib/dhcp/dhclient.ens32.leases, option routers is present and valid.
  • @Jos Although a workaround, your suggestion defeats the purpose of utilizing DHCP to provision network settings. If the default gateway IP address changes in the future, affected machines will need to be updated manually.

I am configuring a Raspberry Pi as a router and ran into the same problem. I fixed it by editing the file /etc/dhcpcd.conf.

Open the file and look for the line:

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes

I simply commented out "option classless_static_routes"

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
# option classless_static_routes

I am now getting an automatic default route set by the DHCP server.

A similar thing could be attempted with dhclient by editing the file /etc/dhcp/dhclient.conf and looking for this line:

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;

and removing the request for rfc3442-classless-static-routes.