Change Interface Name
Change Network Interface Names
By default, CentOS 8 Stream sets the network interfaces like ens192
or ens224
or some other names. However, for some cases, we need to manually set interface's names into eth0
or eth1
like the old days.
1. Modify Grub
Edit /etc/default/grub
and add net.ifnames=0
and biosdevname=0
to the file. Then save the file. Once the file was saved, apply the change using
This will apply the changes into your boot grub system.
2. Add Rules to udev
Before you add rules into udev, you need to identify which network mac addresses are assigned. You can perform this by ifconfig
. Let's say that you have following two interfaces:
ens192
having MAC address of00:0c:29:9a:e1:b0
ens224
having MAC address of00:0c:29:9a:e1:ba
Store those MAC addresses somewhere you are able to remember. Then add rules to /etc/udev/rules.d/
, by adding a new rule named 70-persistent-net.rules
Add following content inside the file:
Replace MAC_ADDRESS
with the real MAC address that was retrieved earlier. Also, change eth0
to some other name that you wish to use. An example shall be like below:
3. Add network-scripts
If you have finished till the step 2 and reboot the system, the interface will have correct name with correct MAC address. However, it will NOT have a IP assigned to the interface. In order to add IPs into the interface, add network scripts by creating a new network-scripts and let the OS do the job.
Then you will be able to see old network script files that were used before. If you have located those files, rename them and modify the contents accordingly for the new interface. For example, if we had interface named ens192
, there will be a network script named ifcfg-ens192
. Just copy the fle into ifcfg-eth0
and modify some contents inside it:
Edit the content like below:
Set DHCP or other optioins accordinlgy, but set NAME
and DEVICE
as the ones that we were trying to set into.
Be aware that latest versions of CentOS like CentOS9, the network-scripts are deprecated. Therefore, look for other ways to automatically assign IP addresses to an interface on the web.
4. Reboot
Once step 1 ~ 3 were done, it's time for reboot. Once, the machine was rebooted, use ifconfig
and look for the network interfaces:
Both names of interfaces were changed successfully.
'
Last updated