And interesting script anyway: Given an IP address, find the mdns (AKA ZeroConf or Bonjour; formerly Rendezvous) name - which might help give you a better idea who's there):
#!/bin/bash
# use mdns (local subnet only) to show machine name for a given host IP addr
# (ex: for machines w/ DHCP addrs and therefore unintersting domain names)
if [ -z "$1" ] ; then echo "must supply a host as 1st/only arg"; exit; fi
if [ -n "$2" ] ; then echo "must supply only one arg"; exit; fi
# is it necessary to ping it first, to make sure it's in the ARP table?
#if ! $(ping -c1 "$1") ; then echo "error pinging host"; exit; fi
if ! arpOutput=$(arp "$1") ; then echo "error in arp host"; exit; fi
arpMAC=$(echo "$arpOutput" | sed 's/.*\([a-zA-Z0-9]\{1,2\}:[a-zA-Z0-9]\{1,2\}:[a-zA-Z0-9]\{1,2\}:[a-zA-Z0-9]\{1,2\}:[a-zA-Z0-9]\{1,2
\}:[a-zA-Z0-9]\{1,2\}\).*/\1/g')
arpMAC=$(echo "$arpMAC" | sed 's/^\(.\):/0\1:/' | sed 's/:\(.\):/:0\1:/g' | sed 's/:\(.\):/:0\1:/g')
echo "starting mdns browse; you'll have to hit ^C to get control back..."
dns-sd -B _workstation._tcp | grep "$arpMAC"
# end
No comments:
Post a Comment