From 814fac877b22577f4835afcfb2597677270f6a4c Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Mon, 8 Oct 2012 14:53:09 +0200 Subject: check an IP address for existence in ifup-alias (#852005) --- sysconfig.txt | 4 ++++ sysconfig/network-scripts/ifup-aliases | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/sysconfig.txt b/sysconfig.txt index 7746671c..4d87599d 100644 --- a/sysconfig.txt +++ b/sysconfig.txt @@ -586,6 +586,10 @@ Files in /etc/sysconfig/network-scripts/ Network zone (trust level) of this connection. If not set, default zone (specified in /etc/firewalld/firewalld.conf) is used. To see all available zones, run 'firewall-cmd --get-zones'. + ARPCHECKn=yes|no + If set to 'no', ifup will not try to determine, if requested ip address + is used by other machine in network. + Defaults to 'yes'. For dynamic addressing (BOOTPROTO=dhcp) only DEVICE needs to be set; all the rest will be determined by the boot protocol. diff --git a/sysconfig/network-scripts/ifup-aliases b/sysconfig/network-scripts/ifup-aliases index a647044f..8a59dd0a 100755 --- a/sysconfig/network-scripts/ifup-aliases +++ b/sysconfig/network-scripts/ifup-aliases @@ -139,6 +139,7 @@ function ini_env () GATEWAY=$default_GATEWAY NO_ALIASROUTING=$default_NO_ALIASROUTING ONPARENT="" + ARPCHECK="" } function is_default_gateway () @@ -256,6 +257,14 @@ function new_interface () fi if [ "$setup_this" = "yes" ] ; then + [ "${parent_device}" != "lo" ] && [ "${ARPCHECK}" != "no" ] && \ + is_available ${parent_device} && \ + grep -qswi "up" /sys/class/net/${parent_device}/operstate && \ + if ! /sbin/arping -q -c 2 -w 3 -D -I ${parent_device} ${IPADDR} ; then + net_log $"Error, some other host already uses address ${IPADDR}." + return 1 + fi + /sbin/ip addr add ${IPADDR}/${PREFIX} brd ${BROADCAST} dev ${parent_device} label ${DEVICE} [ "$IPV6INIT" = "yes" ] && /etc/sysconfig/network-scripts/ifup-ipv6 ${DEVICE} -- cgit v1.2.1