How to get the MAC address of the 'local' system given the IP address?
Chris Green
cl at isbd.net
Thu Jan 30 20:13:58 UTC 2020
On Thu, Jan 30, 2020 at 09:54:44AM -0800, MR ZenWiz wrote:
> On Thu, Jan 30, 2020 at 9:24 AM Chris Green <cl at isbd.net> wrote:
> >
> :
> > ... but I can't find a neat way of getting the corresponding MAC
> > address and company information as for arp-scan. The MAC address can
> > be obtained using ifconfig or ip but it's an exercise in frustration
> > trying to extract the relevant bits:-
> >
> Construct an awk script that takes the output of ifconfig (or ip a)
> and produces the desired MAC address (ether for ifconfig, link/ether
> for ip) if there is one.
>
> You can have it run on all interfaces or just the one you're
> interested in. You can even make it smart enough to find the IP
> address and output just that MAC address.
>
> If you don't know how to use awk, it may take a few tries and a lot of
> man page references, but an exercise in frustration? Sounds to me
> like not enough effort applied. Besides, once you learn to do this,
> more awk scripts become much easier.
>
> You can also do it in a shell script, but that is a little trickier
> and involves more command breadth - awk is simpler.
>
Yes, I fear you may be right, an awk script may be the only way to do
it. I was just hoping for a neater/more elegant way to do it.
--
Chris Green
More information about the ubuntu-users
mailing list