diff options
author | Roy Marples <roy@marples.name> | 2009-12-14 19:31:18 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2009-12-14 19:31:18 +0000 |
commit | a165fbe384ed4851ea42d7fa2d2d74daa0c02f1c (patch) | |
tree | 3162c8fff3cd0978e317e0032bb6ff44b797ed06 | |
parent | 02c12c1caced4c2393e2ca15efdaca56d5f0d452 (diff) |
Support inet6 routes.
-rw-r--r-- | conf.d/network.in | 2 | ||||
-rw-r--r-- | init.d/network.in | 21 | ||||
-rw-r--r-- | init.d/staticroute.in | 11 |
3 files changed, 32 insertions, 2 deletions
diff --git a/conf.d/network.in b/conf.d/network.in index 72019253..68141a71 100644 --- a/conf.d/network.in +++ b/conf.d/network.in @@ -11,6 +11,8 @@ # You can assign a default route #defaultroute="192.168.0.1" +#defaultroute6="2001:a:b:c" + # Lastly, the interfaces variable pulls in virtual interfaces that cannot # be automatically detected. #interfaces="br0 bond0 vlan0" diff --git a/init.d/network.in b/init.d/network.in index 3beba1ca..259fb31c 100644 --- a/init.d/network.in +++ b/init.d/network.in @@ -137,6 +137,7 @@ routeflush() if [ "$RC_UNAME" = Linux ]; then if [ -x /sbin/ip ]; then ip route flush scope global + ip route delete default 2>/dev/null else # Sadly we also delete some link routes, but # this cannot be helped @@ -156,6 +157,8 @@ routeflush() esac route del $flags $dest $netmask $xtra done + # Erase any default dev eth0 routes + route del default 2>/dev/null fi else route -qn flush @@ -263,6 +266,24 @@ start() eend $? fi + if [ -n "$defaultroute6" ]; then + ebegin "Setting default route $defaultroute6" + if [ "$RC_UNAME" = Linux ]; then + routecmd="route -A inet6 add" + if [ "${defaultroute6#dev }" = "$defaultroute6" ]; then + routecmd="$routecmd gw" + fi + else + routecmd="route -inet6 add" + fi + $routecmd default $defaultroute6 + eend $? + elif [ -n "$defaultiproute6" ]; then + ebegin "Setting default route $defaultiproute6" + ip route add default via $defaultiproute6 + eend $? + fi + return 0 } diff --git a/init.d/staticroute.in b/init.d/staticroute.in index 9f38b562..9995d37f 100644 --- a/init.d/staticroute.in +++ b/init.d/staticroute.in @@ -50,7 +50,7 @@ dump_args() do_routes() { - local xtra= + local xtra= family= [ "$RC_UNAME" != Linux ] && xtra=-q ebegin "$1 static routes" @@ -74,7 +74,14 @@ do_routes() ip route $2 $args ;; *) - route $xtra $2 -$args + # Linux route does cannot work it out ... + if [ "$RC_UNAME" = Linux ]; then + case "$args" in + *:*) family="-A inet6";; + *) family=;; + esac + fi + route $famly $xtra $2 -$args ;; esac veend $? |