How to get the MAC address of the 'local' system given the IP address?

Chris Green cl at isbd.net
Thu Jan 30 20:12:37 UTC 2020


On Thu, Jan 30, 2020 at 05:25:33PM +0000, Paul Sladen wrote:
> On Thu, 30 Jan 2020, Chris Green wrote:
> > ... find a neat way of getting the corresponding MAC
> 
> $ grep . /sys/class/net/*/address
> 
> Then look up the vendor prefixes in a copy of 'oui.txt'.
> 
But that gives me:-

    /sys/class/net/enp0s25/address:90:1b:0e:06:bc:91
    /sys/class/net/lo/address:00:00:00:00:00:00

and I don't know which device corresponds to my LAN IP address.  More
significantly if my wired connection is up too there will be three
lines returned.  I want to link the above output to the IP address
returned by 'hostname -i'.

-- 
Chris Green




More information about the ubuntu-users mailing list