Index: 4.2.5-P1-r3/dhclient-exit-hooks =================================================================== --- 4.2.5-P1-r3.orig/dhclient-exit-hooks +++ 4.2.5-P1-r3/dhclient-exit-hooks @@ -4,7 +4,7 @@ # # This file is sourced by /sbin/dhclient-script. # -# dhcp option 121 is defined in RFC3442. The following is the link. +# dhcp option 121 is defined in RFC3442. The following is the link. # http://www.ietf.org/rfc/rfc3442.txt # # The code for this option is 121, and its minimum length is 5 bytes. @@ -52,7 +52,7 @@ function add_routes() { while [ $# -ne 0 ]; do mask=$1 shift - + # Parse the arguments into a CIDR net/mask string if [ $mask -eq 32 ]; then destination="-host $1.$2.$3.$4" @@ -66,22 +66,31 @@ while [ $# -ne 0 ]; do elif [ $mask -gt 8 ]; then destination="-net $1.$2.0.0/$mask" shift; shift + elif [ $mask -gt 0 ]; then + destination="-net $1.0.0.0/$mask" + shift else - destination="-net $1.0.0.0/$mask" - shift + destination="default" fi - + # Read the gateway gateway="$1.$2.$3.$4" shift; shift; shift; shift - # Add route into routing table - route add $destination gw $gateway - - # Print it out if the route is added successfully - if [ $? = 0 ]; then - echo "Added route \"$destination gw $gateway\"" + if [ $gateway != "0.0.0.0" ]; then + # Add route into routing table + route add $destination gw $gateway + if [ $? = 0 ]; then + echo "Added route \"$destination gw $gateway\"" + fi + else + # Add onlink route into routing table + route add $destination $interface + if [ $? = 0 ]; then + echo "Added route \"$destination on $interface\"" + fi fi + done }