how to determine network device names
Little Girl
littlergirl at gmail.com
Sun Nov 7 17:28:20 UTC 2021
Hey there,
hput via ubuntu-users wrote:
>ubuntu 21.04
>I read that one can determine the possible name of a network device
>by using 'lspci'
[SNIP]
>It seems like I should be able to piece together an enpxxx type
>device name by extrapolating from those examples:
>
>I came up with `enp3s0' but of course when I try that with ifconfig.
>
> ifconfig enp3s0
>
>I just get `error fetching interface information ... device not
>found'
Yep. That's no longer used. I've got a couple of options for you
below, although neither of them uses lspci.
This command will give it to you:
ip address | grep "BROADCAST" | cut -d' ' -f2 | cut -d':' -f1
How the command works:
* The ip address command gets your network configuration and
passes it to the grep command.
* The grep command finds a line of content containing the
"BROADCAST" search term. It passes its findings to the first
cut command.
* The first cut command removes all but the second field,
which is your iface plus a colon after it. It passes its
result to the next cut command.
* The next cut command removes all but the first field, so it
removes the colon, which leaves you with your iface.
This command will also give it to you:
ip route | grep kernel | cut -f2 -d'/' | cut -f3 -d' '
How the command works:
* The ip address command gets your network routing table and
passes it to the grep command.
* The grep command finds a line of content containing the
"kernel" search term. It passes its findings to the first
cut command.
* The first cut command splits the input at forward
slashes and removes all but the second field, which
contains space-separated data. It passes its result to the
next cut command.
* The next cut command splits the input at spaces and removes
all but the third field, which leaves you with your iface.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list