From d195dfc83fec82f9c225e38d8766054f56473209 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 16 Mar 2010 14:35:44 +1100 Subject: [PATCH] Add support for static routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add netcfg configuration option "ROUTES" to setup static routes. This is done regardless of whether the IP address is configured using a DHCP or statically. ROUTES is an array containing entries of the form "DESTINATION[/NETMASK] [via ROUTER]" which are directly used in an “ip route add” command. Signed-off-by: Olivier Mehani --- src/connections/ethernet | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/connections/ethernet b/src/connections/ethernet index 36f6b93..ef81b50 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -130,6 +130,16 @@ ethernet_up() { [[ -n "$DNS2" ]] && echo "nameserver $DNS2" >>/etc/resolv.conf fi + # Add static routes + if [[ -n "$ROUTES" ]]; then + for route in "${ROUTES[@]}"; do + report_debug ethernet_iproute_up ip route add $route dev $INTERFACE + if ! ip route add $route dev $INTERFACE ; then + report_iproute "Adding route '$route' failed" + fi + done + fi + return 0 } -- 1.7.0.2