I think I've found the bug. # diff networking-routes networking-routes~ 115c115 < cat $ROUTEFILE | egrep "^[^#].*$" | --- > cat $ROUTEFILE | egrep "^[^#].*any$" |
now it works with specified network interfaces. I'm not 100% sure why it does; the while loop which collects the lines from the /etc/network/routes file doesn't pass $interfaces through to the route add command. I've patched the file so that it uses ip route add instead of route add and so that the $interfaces is explicitly passed through: --- /etc/init.d/networking-routes 2011-09-13 16:30:57.000000000 -0400 +++ /etc/init.d/networking-routes-ip 2015-10-09 17:58:42.000000000 -0400 @@ -45,7 +45,7 @@ # Place, Suite 330, Boston, MA 02111-1307 USA # -[ -x /sbin/route ] || exit 0 +[ -x /sbin/ip ] || exit 0 ROUTEFILE="/etc/network/routes" # Abort (without error) if the configuration file does not exist [ ! -r "$ROUTEFILE" ] && exit 0 @@ -59,7 +59,7 @@ run_route() { - local COMMAND="route $*" + local COMMAND="ip route $*" export LC_MESSAGES=C # We need the return messages to be in english RETMESSAGE="$($COMMAND 2>&1)" RETVALUE=$? @@ -89,16 +89,16 @@ del_global_routes() { ret=0 - cat $ROUTEFILE | egrep "^[^#].*any$" | + cat $ROUTEFILE | egrep "^[^#].*$" | while read network netmask gateway interface ; do if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then if [ "$gateway" != "reject" ] ; then [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting global route for $network / $netmask through gateway $gateway" - run_route del -net $network netmask $netmask gw $gateway + run_route del $network/$netmask via $gateway dev $interface [ $? -ne 0 ] && ret=$? else [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting reject route for $network / $netmask" - run_route del -net $network netmask $netmask reject + run_route del $network/$netmask reject [ $? -ne 0 ] && ret=$? fi @@ -112,16 +112,16 @@ add_global_routes() { ret=0 - cat $ROUTEFILE | egrep "^[^#].*any$" | + cat $ROUTEFILE | egrep "^[^#].*$" | while read network netmask gateway interface ; do if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then if [ "$gateway" != "reject" ] ; then [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global route for $network / $netmask through gateway $gateway" - run_route add -net $network netmask $netmask gw $gateway + run_route add $network/$netmask via $gateway dev $interface [ $? -ne 0 ] && ret=$? else [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global reject route for $network / $netmask" - run_route add -net $network netmask $netmask reject + run_route add $network/$netmask reject [ $? -ne 0 ] && ret=$? fi