From: Florian Fainelli Date: Thu, 13 Apr 2006 11:38:18 +0000 (+0000) Subject: Add support for static routes per interface. You can specify one or more routes,... X-Git-Tag: whiterussian_rc6~274 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=a749b0eebddfa31f857271e883ffafa81d571c01;p=openwrt%2Fsvn-archive%2Fopenwrt.git Add support for static routes per interface. You can specify one or more routes, subnets or hosts. Closes #308 for whiterussian SVN-Revision: 3628 --- diff --git a/openwrt/package/base-files/default/etc/functions.sh b/openwrt/package/base-files/default/etc/functions.sh index fd0ce0e31b..4af6dceaab 100755 --- a/openwrt/package/base-files/default/etc/functions.sh +++ b/openwrt/package/base-files/default/etc/functions.sh @@ -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