Improve MAC detection

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7676 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-11-16 16:53:02 +00:00
parent 81bd913a08
commit 39f4885b20

View File

@ -912,11 +912,17 @@ find_mac() # $1 = IP address, $2 = interface
{ {
qt ping -nc 1 -t 2 -I $2 $1 qt ping -nc 1 -t 2 -I $2 $1
local result=$(arp -na | awk "/[(]$1[)].* on $2$/ {print \$4}") local result=$(arp -na | awk "/[(]$1[)].* $2$/ {print \$4}")
[ -n "$result" -a "$result" != "<incomplete>" ] || fatal_error "Cannot determine the MAC address of $1 through $2" case $result in
\<*\>)
;;
*)
[ -n "$result" ] && echo $result && return
;;
esac
echo $result fatal_error "Cannot determine the MAC address of $1 through $2"
} }
################################################################################ ################################################################################