Linux Network Interface Naming

From Leo's Notes
Revision as of 21:28, 10 March 2020 by Leo (talk | contribs)
This page was last edited on 10 March 2020, at 21:28.

Enabling old eth0..N interface naming

Modern Linux utilizing systemd names network interfaces after its physical location to ensure predictable network interface names (eg. p2p1 for PCI slot 1, port 1). More information on this can be read at https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

You can bring back the old naming scheme in one of three ways as outlined in the systemd page linked above:

  1. You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's .link file for the default policy: ln -s /dev/null /etc/systemd/network/99-default.link
  2. You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own .link files in /etc/systemd/network/, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See systemd.link(5) for more information.
  3. You pass the net.ifnames=0 on the kernel command line. Do this by editing /etc/default/grub, then applying it with grub2-mkconfig -o /boot/grub2/grub.cfg before rebooting.

Renumbering network interfaces

Do you have network interfaces that no longer start at 0 (eg: eth0, em1, eth1000)? Interface numberings are defined through udev rules. To reset the numbers starting at 0, any old interfaces that was previously found by udev needs to be cleared.

To renumber the interfaces, you can edit the udev rules at /etc/udev/rules.d/70-persistent-net.rules. Remove lines defining the extraneous interfaces that you don't want. Once done, ensure that your network configs are matches up to your new network interface names. (Red Hat based only)

# cd /etc/sysconfig/network-scripts/
# ls ifcfg*

Once completed, reboot the machine.

See Also