]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/ifup.sh:do_static(): error out, if IP is already assigned
authorHarald Hoyer <harald@redhat.com>
Wed, 19 Aug 2015 12:00:28 +0000 (14:00 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 19 Aug 2015 12:00:28 +0000 (14:00 +0200)
modules.d/40network/ifup.sh

index 1ee89bf48e0b3e97380209086d8a6545a46e9df9..e51b453a005166adc0e953141750678e3f6c0b0a 100755 (executable)
@@ -160,6 +160,15 @@ do_static() {
         return 1
     fi
 
+    ip route get "$ip" | {
+        read a rest
+        if [ "$a" = "local" ]; then
+            warn "Not assigning $ip to interface $netif, cause it is already assigned!"
+            return 1
+        fi
+        return 0
+    } || return 1
+
     [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
     [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
     if strstr $ip '*:*:*'; then