Bug 241792 - dhclient/dhclient-script: dhclient default route not working when given a /32 netmask
Summary: dhclient/dhclient-script: dhclient default route not working when given a /32...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
Keywords: patch
Depends on:
Reported: 2019-11-07 21:44 UTC by sigsys
Modified: 2019-11-08 20:09 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description sigsys 2019-11-07 21:44:40 UTC
There's a certain VM where autoconfiguration via DHCP works with Linux but not FreeBSD.  I have no information on how this VM is setup apart that it's hosted with KVM/QEMU.

The DHCP server sends a lease with a /32 netmask.  This makes adding the default route fail since it is not reachable via any interface.  Linux's dhclient-script seem to usually have a special case for that and explicitly adds an interface route to the router's address.

FreeBSD's dhclient-script has a special case for when the router address is the same as the leased address, but not when it's a different address that doesn't fall in the interface's subnet.

With this change, DHCP just works on this VM:

Index: sbin/dhclient/dhclient-script
--- sbin/dhclient/dhclient-script	(revision 354408)
+++ sbin/dhclient/dhclient-script	(working copy)
@@ -173,6 +173,9 @@
			if [ "$new_ip_address" = "$router" ]; then
				route add default -iface $router >/dev/null 2>&1
+				if [ "$new_subnet_mask" = "" ]; then
+					route add "$router" -iface "$interface" >/dev/null 2>&1
+				fi
				route add default $router >/dev/null 2>&1