Network interface name

From HPCWIKI
Jump to navigation Jump to search

The Linux kernel assigns names to network interfaces, nowaday there are multiple network interface naming scheme is available and each has pros and cons.

Simple names scheme

eth0, eth1, etc were simply assigned by the kernel.

Following step would be the simplest way among many possible way ,

Step 1, Add this to the line below "net.ifnames=0 biosdevname=0"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Step 2, Update GRUB, depends on your OS.
Debian based Ubuntu/Mint:
update-grub

Centos/RHEL
grub2-mkconfig -o /boot/grub2/grub.cfg

Step 3, Reboot and check

Persistent names scheme

udev to identify interfaces by MAC address and assign a fixed interface number to any interface by writing the rules to /etc/udev/rules.d/xxx.rules

for example,

#/etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100e (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Predictable names scheme

Predictable Network Interface naming and is part of systemd, to which Ubuntu has been transitioning as of version 15.04. the idea is to set interface name depends on physical location of hardware and can be predicted/guessed by looking at lspci or lshw output.

There are 3 ways how interface name is assigned, Refer here for more

  1. based on BIOS/Firmware for onboard cards
  2. based on PCI information
  3. based on MAC address of the interface

Custome names scheme[1]

Using systemd.link

#/etc/systemd/network/10-persistent-net.link
[Match]
MACAddress=01:23:45:67:89:ab

[Link]
Name=lan0

To verify the new policies to work after a reboot,

  • run udev control --reload (or /etc/init.d/udev force-reload, or service udev force-reload)
  • then
    • for hotplug NICs, disconnect and reconnect them (or unload/reload the driver; if your SSH session doesn't go through this NIC...)
    • for non-hotplug NICs, run udevadm trigger, then check the logs (your SSH connection should still be okay even if your .link file was rejected as nonsense), then restart networking.

It is also possible to reorganize the naming policy by overriding /lib/systemd/network/99-default.link, for instance to insist that all network interfaces are named purely by MAC address:

 #/etc/systemd/network/99-default.link
 [Match]
 OriginalName=*

 [Link]
 NamePolicy=mac
 MACAddressPolicy=persistent

References