On Tue, Dec 03, 2013 at 04:15:10PM -0800, Matthew Dempsky wrote: > The patch below extends dhclient to mimic this logic from ISC DHCP's > linux script: > > if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then > route add -host $router dev $interface > fi > route add default gw $router $metric_arg dev $interface > > With this change, dhclient is able to successfully configure the > network via DHCP on Compute Engine: > > $ ifconfig vio0 > vio0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu > 1500 > lladdr 42:01:0a:f0:8f:56 > priority: 0 > groups: egress > media: Ethernet autoselect > status: active > inet6 fe80::4001:aff:fef0:8f56%vio0 prefixlen 64 scopeid 0x1 > inet 10.240.143.86 netmask 0xffffffff > $ netstat -r -n -f inet > Routing tables > > Internet: > Destination Gateway Flags Refs Use Mtu Prio Iface > default 10.240.0.1 UGS 1 183 - 8 vio0 > 10.240.0.1 42:01:0a:f0:00:01 UHLc 1 0 - 56 vio0 > 10.240.0.1/32 link#1 UC 1 0 - 56 vio0 > 10.240.143.86/32 link#1 UC 0 0 - 4 vio0 > 127/8 127.0.0.1 UGRS 0 0 33144 8 lo0 > 127.0.0.1 127.0.0.1 UH 1 0 33144 4 lo0 > 224/4 127.0.0.1 URS 0 0 33144 8 lo0 > > ok? > > Index: dhclient.c > =================================================================== > RCS file: /cvs/src/sbin/dhclient/dhclient.c,v > retrieving revision 1.268 > diff -u -p -r1.268 dhclient.c > --- dhclient.c 20 Nov 2013 17:22:46 -0000 1.268 > +++ dhclient.c 4 Dec 2013 00:06:08 -0000 > @@ -879,6 +879,21 @@ bind_lease(void) > /* XXX Only use FIRST router address for now. */ > memcpy(&gateway.s_addr, options[DHO_ROUTERS].data, > options[DHO_ROUTERS].len); > + > + /* > + * If we were given a /32 IP assignment, then make sure > + * the gateway address is routable with equivalent of > + * > + * route add -net $gw -netmask 255.255.255.255 \ > + * -cloning -iface $addr > + */ > + if (mask.s_addr == INADDR_BROADCAST) { > + add_route(ifi->rdomain, gateway, mask, > + client->new->address, > + RTA_DST | RTA_NETMASK | RTA_GATEWAY, > + RTF_CLONING | RTF_STATIC); > + } > + > add_default_route(ifi->rdomain, client->new->address, > gateway); > }
Located here, the addition of the 255.255.255.255 route is not done in the presence of DHO_CLASSLESS_STATIC_ROUTES. As I recall only DHO_ROUTERS and DHO_STATIC_ROUTES are incompatible with DHO_CLASSLESS_STATIC_ROUTES. So we may want this chunk to occur unconditionally. .... Ken