|
FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
MAC address to IP
Is there a way be which I can find IP address on a device on the LAN of which I know the MAC address.
I'm trying to automate something for which I need to know the IP of the device which may change. As I'll be using it in the perl script and hopefully port it to C/C++ in future I need a way to do it from the CLI no GUI tool . |
|
|||
problem with this is that it'll work only if that device is in my arp table. Isn't there a way in which LAN can be quarried for MAC address.
|
|
|||
If you mean queried, no.. sounds like you need to brush up on your basic networking skills.
When a system on your network attempts to connect to an IP address, an action not unlike a DNS lookup occurs. Host #1 broadcasts a "Who is Host #2" message to the subnet, Host #2 notices this request and responds to Host #1 saying "That's me, I'm Host #2!". Can you determine the MAC address of every system? Yes.. via brute force, there is no passive method I'm aware of. |
|
||||
Quote:
Quote:
Quote:
Quote:
I think I'll have to come up with some other way. |
|
||||
checkout arpwatch: ftp://ftp.ee.lbl.gov/arpwatch.tar.gz
or maybe this might do: Code:
#!/bin/sh # -ephemera net=10.30.1 # 10.30.1/24 [ $# -lt 1 -o `id -u` -ne 0 ] && exit 1 x=1 while [ $x -le 254 ] ; do arp -d $net.$x >/dev/null 2>&1 printf "\rScanning $net.$x " ping -c3 $net.$x 1>/dev/null & x=$(($x + 1)) done while [ `pgrep -P $$ ping | wc -l` -ne 0 ] ; do printf . sleep 1 done printf " Done.\n" arp -na | grep $1 | sed 's/.*(\(.*\)) at .*/\1 /' Last edited by ephemera; 10th November 2008 at 10:04 PM. |
|
||||
To fill your arp table, just ping the broadcast address for the subnet. For example: ping 192.168.0.255. That will cause every machine on that subnet to respond, and you will get arp entries for every machine on the subnet.
Check the output of ifconfig for the current broadcast address. |
|
||||
Quote:
arpwatch is a really handy (passive) layer 2 sniffer that can help identify network problems. --- I'd also add to all this: Quote:
__________________
Kill your t.v. |
|
||||
Phoenix,
As in the OP's case, suppose host A has an entry in the arp cache for host B. B changes its IP before A's arp cache expires. Now if A tries to send a packet (using the stale cache entry) to B then what will happen? And is it documented or implementation dependent? Last edited by ephemera; 11th November 2008 at 07:14 PM. |
Tags |
arp, ip, mac |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Script to test whether an IP address has been listed in a DNSBL | J65nko | Guides | 12 | 2nd February 2016 03:30 AM |
could not look up internet address for .lan | idefix | FreeBSD General | 2 | 31st January 2009 02:22 PM |
Changing MAC address to an alias interface? | DNAeon | FreeBSD General | 6 | 20th January 2009 04:48 PM |
Static IP address problem | rex | FreeBSD General | 2 | 25th November 2008 08:53 PM |
Asking about IPv6 address | berlowin | Off-Topic | 2 | 9th July 2008 02:39 AM |