Linux Network Interface Naming: Difference between revisions

From Leo's Notes
This page was last edited on 10 March 2020, at 21:28.
m Leo moved page Renaming / Renumbering Network Interfaces to Linux Network Interface Naming: Adding more info to network interfaces in general
No edit summary
Line 1: Line 1:
Do you have network interfaces that no longer start at 0 (eg: eth0, em1, etc...)?


== Edit udev Rules ==
== Enabling old {{code|eth0..N}} interface naming ==
To renumber the interfaces, you can edit the udev rules at:
Modern Linux utilizing systemd names network interfaces after its physical location to ensure predictable network interface names (eg. {{code|p2p1}} for PCI slot 1, port 1). More information on this can be read at https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
{{highlight|lang=text|code=
 
/etc/udev/rules.d/70-persistent-net.rules
You can bring back the old naming scheme in one of three ways as outlined in the systemd page linked above:
}}
# You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's {{code|.link}} file for the default policy: {{code|ln -s /dev/null /etc/systemd/network/99-default.link}}
# You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own {{code|.link}} files in {{code|/etc/systemd/network/}}, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See {{code|systemd.link(5)}} for more information.
# You pass the {{code|1=net.ifnames=0}} on the kernel command line. Do this by editing {{code|/etc/default/grub}}, then applying it with {{code|grub2-mkconfig -o /boot/grub2/grub.cfg}} before rebooting.


Remove lines defining the extraneous interfaces that you don't want. Once done, ensure that your network configs are correct (Red Hat based only)
== Renumbering network interfaces ==
Do you have network interfaces that no longer start at 0 (eg: {{code|eth0}}, {{code|em1}}, {{code|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 {{code|/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)
{{highlight|lang=text|code=
{{highlight|lang=text|code=
# cd /etc/sysconfig/network-scripts/
# cd /etc/sysconfig/network-scripts/
Line 14: Line 17:
}}
}}


Ensure the scripts matches up to the interfaces you defined in the udev rules. Once completed, reboot the machine.
Once completed, reboot the machine.  
 


== See Also ==
== See Also ==

Revision as of 21:28, 10 March 2020

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