From: Evan Hunt Date: Thu, 31 May 2018 03:07:53 +0000 (-0700) Subject: use "ip" on linux, falling back to "ifconfig" when it isn't available X-Git-Tag: v9.9.13rc1~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e56d78c6eb04a1f487ba2d090c74b6ff6c3921d;p=thirdparty%2Fbind9.git use "ip" on linux, falling back to "ifconfig" when it isn't available (cherry picked from commit d7c54007985609133a8fd22b451a0c43b00defcf) (cherry picked from commit 3e1a0c2b62b80d30a01eb4054fc1e1594f91355e) --- diff --git a/bin/tests/system/ifconfig.sh b/bin/tests/system/ifconfig.sh index 8e9fc38a78d..02ddfa00dc8 100755 --- a/bin/tests/system/ifconfig.sh +++ b/bin/tests/system/ifconfig.sh @@ -53,6 +53,20 @@ case `uname -a` in *) sys=`sh $config_guess` ;; esac +use_ip= +case "$sys" in + *-*-linux*) + if type ip > /dev/null; then + use_ip=yes + elif type ifconfig > /dev/null; then + : + else + echo "$0: can't find ip or ifconfig" >&2 + exit 1 + fi + ;; +esac + case "$1" in start|up) @@ -85,10 +99,18 @@ case "$1" in inet6 fd92:7065:b8e:${ipv6}ff::$ns up ;; *-*-linux*) - ifconfig lo:$int 10.53.$i.$ns up \ - netmask 255.255.255.0 - [ "$ipv6" ] && ifconfig lo inet6 add \ - fd92:7065:b8e:${ipv6}ff::$ns/64 + if [ $use_ip ]; then + ip address add 10.53.$i.$ns/24 \ + dev lo:$int + [ "$ipv6" ] && ip address add \ + fd92:7065:b8e:${ipv6}ff::$ns/64 \ + dev lo + else + ifconfig lo:$int 10.53.$i.$ns up \ + netmask 255.255.255.0 + [ "$ipv6" ] && ifconfig lo inet6 add \ + fd92:7065:b8e:${ipv6}ff::$ns/64 + fi ;; *-unknown-freebsd*) ifconfig lo0 10.53.$i.$ns alias \ @@ -180,9 +202,17 @@ case "$1" in ifconfig lo0:$int inet6 unplumb ;; *-*-linux*) - ifconfig lo:$int 10.53.$i.$ns down - [ "$ipv6" ] && ifconfig lo inet6 \ - del fd92:7065:b8e:${ipv6}ff::$ns/64 + if [ $use_ip ]; then + ip address del 10.53.$i.$ns/24 \ + dev lo:$int + [ "$ipv6" ] && ip address del \ + fd92:7065:b8e:${ipv6}ff::$ns/64 \ + dev lo + else + ifconfig lo:$int 10.53.$i.$ns down + [ "$ipv6" ] && ifconfig lo inet6 \ + del fd92:7065:b8e:${ipv6}ff::$ns/64 + fi ;; *-unknown-freebsd*) ifconfig lo0 10.53.$i.$ns delete