1

As mentioned here since Ubutnu 15.10 there are some different naming schemes for network interfaces supported:

  • Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)
  • Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)
  • Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0)
  • Names incorporating the interfaces's MAC address (example: enx78e7d1ea46da)
  • Classic, unpredictable kernel-native ethX naming (example: eth0) - depreciated

I am writing a script that takes interface name with grep:

if_name=$(ls /sys/class/net | grep "en")

and then changes it to eth. I've tested script on a few machines and it was fine, but is there a chance that interface name now can start from another letters and my command above won't work? And if so, are there any better alternatives?

Community
  • 1
  • 1
Bohdan Blyzniuk
  • 575
  • 6
  • 14
  • Yes there is a better way than doing some bash script for it. Have a look at the why/how this was done [here](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/), and especially the section "I don't like this, how do I disable this?" – jbm Apr 02 '16 at 06:30
  • Thank you, that's exactly what i am doing in my script, but before that, i need to invoke current interface name and current MAC address, that belongs to its name. – Bohdan Blyzniuk Apr 02 '16 at 08:52
  • Yes, and that is why you _do not want to to that in a script_, but rather _automatically at system startup_ , following the pointers in "I don't like this, how do I disable this?" link I provided. Otherwise you have a chicken and egg problem. – jbm Apr 02 '16 at 08:56

1 Answers1

1

Ok, I found out here that two character prefixes based on the type of interface:

 *   en -- Ethernet
 *   sl -- serial line IP (slip)
 *   wl -- wlan
 *   ww -- wwan

Also, the best way to find out you primary interface name:

route |grep default |awk  ' {print $8} '
Bohdan Blyzniuk
  • 575
  • 6
  • 14