1ecb72b961
git-svn-id: svn://svn.openwrt.org/openwrt/packages@16712 3c298f89-4303-0410-b956-a3cf2f4a3e73
30 lines
366 B
Bash
30 lines
366 B
Bash
#!/bin/sh
|
|
|
|
ARP=arp
|
|
MACTODEV=mac-to-devinfo
|
|
|
|
IP=$1
|
|
|
|
if [ -z "$IP" ]; then
|
|
echo "Must specify IP address"
|
|
fi
|
|
|
|
if [ ! -x "$(which $ARP)" ]; then
|
|
do_arp() {
|
|
cat /proc/net/arp
|
|
}
|
|
ARPMACFIELD=4
|
|
else
|
|
do_arp() {
|
|
$ARP -n
|
|
}
|
|
ARPMACFIELD=3
|
|
fi
|
|
|
|
ping -q -c 2 $IP >/dev/null
|
|
MAC=$(do_arp|grep "$IP "|tr -s \ | cut -f$ARPMACFIELD -d\ )
|
|
|
|
$MACTODEV $MAC
|
|
|
|
|