From a749b0eebddfa31f857271e883ffafa81d571c01 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Thu, 13 Apr 2006 11:38:18 +0000 Subject: [PATCH] Add support for static routes per interface. You can specify one or more routes, subnets or hosts. Closes #308 for whiterussian SVN-Revision: 3628 --- openwrt/package/base-files/default/etc/functions.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.30.2