Add support for static routes per interface. You can specify one or more routes,...
authorFlorian Fainelli <[email protected]>
Thu, 13 Apr 2006 11:38:18 +0000 (11:38 +0000)
committerFlorian Fainelli <[email protected]>
Thu, 13 Apr 2006 11:38:18 +0000 (11:38 +0000)
SVN-Revision: 3628

openwrt/package/base-files/default/etc/functions.sh

index fd0ce0e31ba10914a9dd48cb1c0ff7de10bb8418..4af6dceaabfbbbf381fb0c822bcc11ad608e9b9c 100755 (executable)
@@ -37,10 +37,22 @@ do_ifup() {
                netmask=$(nvram get ${2}_netmask)
                gateway=$(nvram get ${2}_gateway)
                mtu=$(nvram get ${2}_mtu)
+               static_route=$(nvram get ${2}_static_route)
 
                $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} ${mtu:+mtu $(($mtu))} broadcast + up
                ${gateway:+$DEBUG route add default gw $gateway}
 
+               [ -n "$static_route" ] && {
+                       for route in $static_route; do
+                               if [ "$(echo $route | cut -d \/ -f2)" != "32" ];
+                               then
+                                       route add -net $(echo $route | cut -d \/ -f1) netmask $(echo $route | cut -d \/ -f1) dev $if
+                               else
+                                       route add -host $(echo $route | cut -d \/ -f1) dev $if
+                               fi
+                       done
+               }
+
                [ -f /etc/resolv.conf ] || {
                        debug "# --- creating /etc/resolv.conf ---"
                        for dns in $(nvram get ${2}_dns); do