How to get the MAC address of the 'local' system given the IP address?
Little Girl
littlergirl at gmail.com
Fri Jan 31 11:23:55 UTC 2020
Hey there,
Ken D'Ambrosio wrote:
>I humbly submit you should *not* use "hostname -i":
>ken at strider ~ $ hostname -i
>127.0.1.1
>
>Not sure where it pulls that from, but localhost is probably not
>what you're really wanting, so unless you understand the mechanics,
>there's more than one way to write a script.
It's case-sensitive. A lower-case i (hostname -i) returns localhost
and an upper-case I (hostname -I) returns the LAN IP.
Here's another way to get the LAN IP by using the ip command:
ip route | grep kernel | cut -f1 -d'/'
I also had that command in my notes written this way, but can't
remember why:
ip route | grep kernel | cut -f1 -d' ' | cut -f1 -d'/'
Both give the same result on my computer, but maybe only one will
work on certain systems or networks.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list