finding remote MAC address
bscott at ntisys.com
bscott at ntisys.com
Tue Apr 29 11:36:02 EDT 2003
On Tue, 29 Apr 2003, at 11:09am, derek at derek.homeunix.org wrote:
> I need to write a script that will take in a list of IP's, and from that
> list find the mac address for these IP's so we can make our move over to
> dhcp.
Are all of these IP addresses on the same layer two broadcast domain?
For example, are they all plugged into the same Ethernet switch (or set of
switches)?
If so, all you need to do is "touch" each one using any IP-based protocol.
That will cause an ARP lookup for the MAC address on the host you are
testing from. "ping" works well for this. Paul's suggestion of "fping"
is also good, but if you have a *lot* of hosts, that might lead to a large
or even overflow'ed ARP table.
Once you've "touched" the host in question, you can then use the "arp"
command to see the result. I suggest the "-n" switch to ARP to turn off
name resolution. To find the MAC address for a particular IP address, use
something like this
arp -n | fgrep 192.168.10.22
If the hosts are separated by one or more IP routers, things become more
difficult. The basic idea is the same, but you will need to get much more
sophisticated. Briefly describe the network topology and lower-level
protocols in use if this is the case; there may be shortcuts you can take.
--
Ben Scott <bscott at ntisys.com>
| The opinions expressed in this message are those of the author and do |
| not represent the views or policy of any other person or organization. |
| All information is provided without warranty of any kind. |
More information about the gnhlug-discuss
mailing list