diff options
author | Kristof Provost <kp@FreeBSD.org> | 2022-10-05 10:11:07 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2022-10-13 07:56:54 +0000 |
commit | 80e991888d79e036c03461d8264eea08a1dc67d8 (patch) | |
tree | 36b2411acb1470d1a462ae050f4d27c24458bbff /sbin | |
parent | e70ce8d3ae1ba3d73e8efe833c941cda6a3bcf5a (diff) | |
download | src-80e991888d79e036c03461d8264eea08a1dc67d8.tar.gz src-80e991888d79e036c03461d8264eea08a1dc67d8.zip |
dhclient-script: cope with /32 address leases
On certain cloud platforms (Google Cloud, Packet.net and others) the
DHCP server offers a /32 address. 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 already has a special case for when the router
address is the same as the leased address. Now also add one for when
it's a different address that doesn't fall in the interface's subnet.
PR: 241792
Event: Aberdeen hackathon 2022
Submitted by: sigsys@gmail.com
Reviewed by: dch, kp, bz (+1 on the idea, not reviewed), thj
MFC after: 1 week
(cherry picked from commit fd6ecc184dbc64b9b3f7866b34812fb93df62925)
Diffstat (limited to 'sbin')
-rwxr-xr-x | sbin/dhclient/dhclient-script | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script index 3439fd960773..c5649e1a1d2a 100755 --- a/sbin/dhclient/dhclient-script +++ b/sbin/dhclient/dhclient-script @@ -173,6 +173,10 @@ add_new_routes() { if [ "$new_ip_address" = "$router" ]; then route add default -iface $router >/dev/null 2>&1 else + if [ "$new_subnet_mask" = "255.255.255.255" ]; then + route add "$router" -iface "$interface" >/dev/null 2>&1 + fi + route add default $router >/dev/null 2>&1 fi fi |