Introduction
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.
- * Two character prefixes based on the type of interface:
- * en -- ethernet
- * sl -- serial line IP (slip)
- * wl -- wlan
- * ww -- wwan
- *
- * Type of names:
- * b
-- BCMA bus core number - * ccw
-- CCW bus group name - * o
-- on-board device index number - * s
[f ][d ] -- hotplug slot index number - * x
-- MAC address - * [P
]p s [f ][d ] - * -- PCI geographical location
- * [P
]p s [f ][u ][..]1[i<interface>] - * -- USB port number chain
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.
Then run this command to regenerate GRUB configuration with updated kernel parameters.
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.
Finally, reboot the machine, and verify the new interface name.
Note that it is still your responsibility to configure the renamed interface. If the network configuration (e.g., IPv4 settings, firewall rules) is based on the old name (before change), you need to update network configuration to reflect the name change.
Supplement
* CentOS : Manual IP network configuration
沒有留言:
張貼留言