Rhel-8 new custom NIC names helper - net.ifnames.prefix
Updated
The project itself is maintained here: https://github.com/msekletar/prefixdevname
It is fully integrated into the rhel-8 and a user does not need to do anything to make it ready for use. The only thing that a user needs to do to use it is to introduce kernel cmd param net.ifnames.prefix=
Note that if this new helper is used to already installed system the NIC names will change and additional steps are required like adjusting ifcfg files etc.
An example of changing the NIC names from systemd naming scheme to custom names like lan[1,2,....]:
# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-87.el8.x86_64 root=/dev/mapper/rhel_unused-root ro crashkernel=auto resume=/dev/mapper/rhel_unused-swap rd.lvm.lv=rhel_unused/root rd.lvm.lv=rhel_unused/swap
# ip l | grep ^[1,2,3,4]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
4: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
# ls -l /etc/systemd/network/
total 0
# grubby --update-kernel=$(grubby --default-kernel) --args="net.ifnames.prefix=lan"
#reboot
# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-87.el8.x86_64 root=/dev/mapper/rhel_unused-root ro crashkernel=auto resume=/dev/mapper/rhel_unused-swap rd.lvm.lv=rhel_unused/root rd.lvm.lv=rhel_unused/swap net.ifnames.prefix=lan
# ip l | grep ^[1,2,3,4]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: lan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
3: lan2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
4: lan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
# ls -l /etc/systemd/network/
total 12
-rw-r--r--. 1 root root 55 May 17 10:23 71-net-ifnames-prefix-lan0.link
-rw-r--r--. 1 root root 55 May 17 10:23 71-net-ifnames-prefix-lan1.link
-rw-r--r--. 1 root root 55 May 17 10:23 71-net-ifnames-prefix-lan2.link
Going back from these custom NIC names to some other approach requires:
- updating the kernel command line arg
# grubby --update-kernel=$(grubby --default-kernel) --remove-args="net.ifnames.prefix=lan"
- removing all the previously created udev rules like
# rm -rf /etc/systemd/network/*lan[0-9]*
#reboot
There are some limitations as well:
- User-defined prefix must be ASCII string that matches following regular expression, [[:alpha:]]+ and must be shorter than 15 characters.
- Your prefix can not conflict with any other well-known prefix used for NIC naming on Linux. Specifically you can't use any of the following prefixes:
- eth
- eno
- ens
- em
SBR
Product(s)
Category
Article Type