Traditionally, network interfaces in Linux are enumerated as eth[0123…], but these names do not necessarily correspond to actual hardware slots, PCI geography, USB port number, etc. This introduces a unpredictable naming problem (e.g., due to undeterministic device probing behavior) which can cause various network misconfigurations (e.g., disabled interface or firewall bypass resulting from unintentional interface renaming). MAC address based udev rules are not so much helpful in a virtualized environment where MAC addresses are as euphemeral as port numbers.
CentOS/RHEL 6 has introduced a method for consistent and predictable network device naming for network interfaces. These features uniquely determine the name of network interfaces in order to make locating and differentiating the interfaces easier and in such a way that it is persistent across later boots, time, and hardware changes. However, this naming rule is not turned on by default on CentOS/RHEL 6.
Starting with CentOS/RHEL 7, the predictable naming rule is adopted by default. Under this rule, interface names are automatically determined based on firmware, topology, and location information. Now interface names stay fixed even if NIC hardware is added or removed without re-enumeration, and broken hardware can be replaced seamlessly.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
* Two character prefixes based on the type of interface: * en -- ethernet * sl -- serial line IP (slip) * wl -- wlan * ww -- wwan * * Type of names: * b<number> -- BCMA bus core number * ccw<name> -- CCW bus group name * o<index> -- on-board device index number * s<slot>[f< function >][d<dev_port>] -- hotplug slot index number * x<MAC> -- MAC address * [P<domain>]p<bus>s<slot>[f< function >][d<dev_port>] * -- PCI geographical location * [P<domain>]p<bus>s<slot>[f< function >][u<port>][..]1[i<interface>] * -- USB port number chain |
A minor disadvantage of this new naming scheme is that the interface names are somewhat harder to read than the traditional names. For example, you may find names like enp0s3. Besides, you no longer have any control over such interface names.
If, for some reason, you prefer the old way, and want to be able to assign any arbitrary name of your choice to an interface on CentOS/RHEL 7, you need to override the default predictable naming rule, and define a MAC address based udev rule.
Here is how to rename a network interface on CentOS or RHEL 7.
First, let’s disable the predictable naming rule. For that, you can pass “net.ifnames=0” kernel parameter during boot. This is achieved by editing /etc/default/grub and adding “net.ifnames=0” to GRUB_CMDLINE_LINUX variable.
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.13.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.13.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-11510efe0881461cb2aa7cb613f65395
Found initrd image: /boot/initramfs-0-rescue-11510efe0881461cb2aa7cb613f65395.img
done
Next, edit (or create) a udev network naming rule file (/etc/udev/rules.d/70-persistent-net.rules), and add the following line. Replace MAC address and interface with your own.
Recent Comments