SHA256
1
0
forked from pool/dhcp
dhcp/dhcp-3.0.6-dhclient-script-default-gw.patch

28 lines
1.1 KiB
Diff

--- dhcp-3.0.6/client/scripts/linux
+++ dhcp-3.0.6/client/scripts/linux 2008/04/04 07:38:57
@@ -284,7 +284,23 @@
route add -net $new_network_number $new_subnet_arg dev $interface
fi
for router in $new_routers; do
- route add default gw $router
+ err=`route add default gw $router 2>&1` && break || \
+ case "$err" in
+ SIOCADDRT:*)
+ # The gateway seems to be not reachable via local network
+ # route (implicitely created by ifconfig based on the IP
+ # an netmask provided by dhcp).
+ # Check this, set an explicit host route to the gateway
+ # over the current interface and try again (bnc#266215).
+ matches=$(test -x /sbin/ip && \
+ /sbin/ip -f inet -o route list match $router | \
+ grep -v ^default | grep -c -v "^$" 2>/dev/null)
+ if test -n "$matches" -a $(($matches)) -eq 0 ; then
+ route add -host $router dev $interface && \
+ route add default gw $router && break
+ fi
+ ;;
+ esac
done
fi
fi