Skip to content

Instantly share code, notes, and snippets.

@chadmayfield
Last active June 3, 2019 19:36
Show Gist options
  • Save chadmayfield/013668e0bccac5fda663aec916f7b18e to your computer and use it in GitHub Desktop.
Save chadmayfield/013668e0bccac5fda663aec916f7b18e to your computer and use it in GitHub Desktop.
Notes on Network Interfaces in Linux/Unix systems

Network Interface Notes

Beginning in Systemd v197, network interfaces assigned by systemd/udev are "predicatble";

Names are now based on;

  • Index numbers for on-board devices (eno1)
  • PCI-ehotplug slot index numbers (ens1)
  • Physical/geographical location of hardware connector (enp2s0)
  • MAC address (enx78e7d1ea46da)
  • Classic, unpredictable kernel-native naming (eth0)

Links;

Two character prefixes based on the type of interface:
 *   en -- ethernet
 *   sl -- serial line IP (slip)
 *   wl -- wlan
 *   ww -- wwan

SO Answer: Find available network interfaces

Find network interface

ls /sys/class/net | grep -E "^e(m|n(o|p|s)|th)[0-9]|wl(an|p)"
find /sys/class/net ! -type d | xargs --max-args=1 realpath  | awk -F\/ '/pci/{print $NF}'

Find available network interfaces

ip r | grep " src "|cut -d " " -f 3,12 | xargs
ip addr show | awk '/inet.*brd/{print $NF}'
ip -o link show up | awk -F': ' '{print $2}'
ip -o -4 addr show
ip -o link ls up
lshw -class network

Observed Interface Names

em1
eno1
enp0s31f6
enp0s29u1u2
enp2s0
enp2s0f1
enp5s0
enp7s0
ens1
enx78e7d1ea46da
eth0
p7p1

wlan0
wlp0s12f0
wlp3s0
wlp3s0b1
wlp19s0

wwp0s29u1u4i6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment