aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig')
-rwxr-xr-xsysconfig/network-scripts/ifdown-post5
-rw-r--r--sysconfig/network-scripts/network-functions31
2 files changed, 36 insertions, 0 deletions
diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post
index 460b072c..49dfa5b4 100755
--- a/sysconfig/network-scripts/ifdown-post
+++ b/sysconfig/network-scripts/ifdown-post
@@ -8,6 +8,11 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
source_config
+# Reset the default route if this interface had a special one
+if ! check_default_route ; then
+ add_default_route
+fi
+
# Notify programs that have requested notification
do_netreport
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index feea9922..93ef3b40 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -59,3 +59,34 @@ check_device_down ()
return $retcode
}
+check_default_route ()
+{
+ return `/sbin/route -n|gawk 'BEGIN{r=1} $3=="0.0.0.1" && $4=="UG" {r=0} END{print r}'`
+}
+
+find_gateway_dev ()
+{
+ . /etc/sysconfig/network
+ if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ] ; then
+ export GATEWAY
+ networks=`/sbin/route -n|awk '{print $1, ENVIRON["GATEWAY"],$3,$8}'|awk '{system("ipcalc --silent --network "$2" "$3" 2>/dev/null")}'|sed s^NETWORK=^^g`
+ for net in $networks; do
+ dev=`/sbin/route -n|grep ^$net|awk '{print $NF}'`
+ if [ "$dev" != "" ] ; then
+ GATEWAYDEV=$dev
+ fi
+ done
+ fi
+}
+
+add_default_route ()
+{
+ . /etc/sysconfig/network
+ find_gateway_dev
+ if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" -a "${GATEWAYDEV}" != "" ] ; then
+ DEVICE=$GATEWAYDEV
+ if ! check_device_down ; then
+ /sbin/route add default gw ${GATEWAY} ${GATEWAYDEV}
+ fi
+ fi
+}