No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search


To have a better experience, please upgrade your IE browser.

Knowledge Base

FAQ: How Do I Change the Network Port Name in a Red Hat 7 OS?

Publication Date:  2019-05-17  |   Views:  1218  |   Downloads:  0  |   Author:  wWX465804  |   Document ID:  EKB1100015529


Issue Description

In Red Hat 7.x OS, the network port naming rule is changed to enp…. Perform the following steps to change network port names from enp… to ethx….


Change a network port name in a Red Hat 7 OS.
Changing the network port name ens33 to eth0 is used as an example.

1. Disable the NetworkManager service first by running the systemctl stop NetworkManager command.

2. Change certain parameters in the configuration file of the ens33 NIC.
   (1) Run the [root@test2 Desktop]# cd /etc/sysconfig/network-scripts command to access the corresponding directory.
   (2) Run the [root@test2 network-scripts]# vi ifcfg-ens33 command to open the configuration file.
   (3) Change the value of NAME=ens33 in the configuration file to NAME=eth0. If the parameter DEVICE=ens33 exists, change it to DEVICE=eth0.

Note: After the NetworkManager service is disabled, if there is no configuration files of the network port, you need to manually add a configuration file. Each network portmust have a configuration file. The content of the configuration file is as follows:

   (4) Run the [root@test2 network-scripts]# mv ifcfg-ens33 ifcfg-eth0 command to rename the configuration file ifcfg-ens33 as ifcfg-eth0.


 3.  Change the GRUB configuration file to so that the kernel cannot continue to use the naming rule.
(1) Run the [root@test2 network-scripts]# vi /etc/sysconfig/grub command to open the file.

(2) Add net.ifnames=0 biosdevname=0 behind the variable (vconsole.keymap=us rhgb quiet) of the GRUB_CMDLINE_LINUX as follows:
GRUB_CMDLINE_LINUX=" crashkernel=auto vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quietnet.ifnames=0 biosdevname=0"
(3) Run the [root@test2 network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg command to regenerate the GRUB configuration and update kernel parameters.


4. Add an udev rule.
    (1) Run the [root@test2 network-scripts]# cd /etc/udev/rules.d command to access the corresponding directory.

    (2) Run the [root@test2 network-scripts]# vi 70-persistent-net.rules command to open the rule file.
    (3) Change the 70-persistent-net.rules file in /etc/udev/rules.d directory. (If the file does not exist, create it. The file name may not be 70-persistent-net.rules, but it also ends with .rules.)


Note: Add the following command: (If you want to change names of several network ports, you need to add several commands. Make sure the one-to-one matching between network port MAC address and NAME.) For example, run the following command:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="Network port MAC address", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

5. If the system is configured with static routes, you need to change the static-routes file. If not, skip this step.
Change the /etc/sysconfig/static-routes file. If the file does not exist, create it.
Note: If there is more than one network port, you need to add default routes.
Run the [root@test2 network-scripts]# cd /etc/sysconfig command to access the corresponding directory.
Run the [root@test2 network-scripts]# vi static-routes command to open the file.
Add default routes:
Run the any net default gw gateway command.
For example, net default gw

6. Restart the network service.
Run the [root@test2 network-scripts]# systemctl restart network command.
If the change does not work, restart the host (a server or a computer).