]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
do 'ip route replace default' instead of 'add'
authorWill Woods <wwoods@redhat.com>
Thu, 28 Aug 2014 17:44:47 +0000 (13:44 -0400)
committerHarald Hoyer <harald@redhat.com>
Fri, 12 Sep 2014 08:22:21 +0000 (10:22 +0200)
When you define the gateway for an interface, dracut sets it up with:

  ip route add default via $gw dev $netif

If a default route is already set (e.g. if you have multiple NICs), this
will fail with the message "RTNETLINK answers: File exists".

So, if your first NIC isn't usable as a default route

Using "ip route replace default" instead allows ifup/dhclient-script to
correctly change the default route to the new interface.

modules.d/40network/dhclient-script.sh
modules.d/40network/ifup.sh

index 0d0d8c9509d9a624078ee427d31766db2d63deba..50f1985b5523e07b8618ad070d1703a505c088af 100755 (executable)
@@ -43,7 +43,7 @@ setup_interface() {
         valid_lft ${lease_time} preferred_lft ${lease_time} \
         dev $netif
 
-    [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
+    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
 
     [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
     if  [ -n "$namesrv" ] ; then
index a8377a48dee4356f7da96a5fdf0bcdd0a8243903..66a3ff436c8571dd4ffafc8fc8e32f7e6267555d 100755 (executable)
@@ -143,7 +143,7 @@ do_static() {
         ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
     fi
 
-    [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
+    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
     [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
 
     return 0