Knowledgebase
emscom > emscom Help Desk > Knowledgebase

Search help:


Centos 7 rename ethernet interface

Solution

Problem: By default Centos 7 assigns a clumsy device name to the Ethernet interface

Resolution: Assign a different device name to the interface

Update: June 2018

CentOS 7.5 build 1804. A further file is implicated by udev and will override the earlier methods of renaming interfaces

/etc/udev/rules.d/90-eno-fix.rules

#This file was automatically generated on systemd update

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR={address}=="00:11:22:33:44:55", NAME="em1"

 

Update: March 2017

Centos 7.3 the most straight forward method appears to be as follows

Assume the Ethernet interface has been assigned a device name of eno1780032

ip link set eno1780032 down
ip link set eno1780032 name em1
ip link set em1 up

The name change can be verified with the commands, ip link, nmcli c but will not persist a reboot

To make the change persistent create the ifcfg- script using nmtui to change the NetworkManager connection profile name, to Ethernet1

cd /etc/sysconfig/network-scripts
cp ifcfg-Ethernet1 ifcfg-em1
nano ifcfg-em1
HWADDR=00:11:22:33:44:55   #Your Ethernet mac address
DEVICE=em1
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=Ethernet1    #NetworkManager profile name
UUID=4f95e671-6cd0-473a-odc3-a1b9eefa9cce    #NetworkManager assigned UUID
ONBOOT=yes

 

Save the file and disable the script created by nmtui

mv ifcfg-Ethernet1 old-ifcfg-Ethernet1

Reboot

 

After reboot verify the interface is operating with the correct device name with

ip addr

End

 

 

Previous instructions deprecated by Centos 7.3

By default, Centos (RHEL) 7 uses a new interface naming convention, whereby the first subnet octet may be used as the postfix

ens192

There are a number of ways to rename the interface however, the most straightforward method is to edit the udev device mapper rules which are read during boot up.

Example: Rename the ens192 interface to em1

Command: nano /usr/lib/udev/rules.d/60-net.rules

Edit the default entry

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"

As follows

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", NAME="em1"

Save and reboot

 

Additional

rename the ifcfg-eno... file in /etc/sysconfig/networ-scripts/

mv ifcfg-eno... ifcfg-em1
nano ifcfg-em1
TYPE=Ethernet
DEVICE=em1
NAME="System em1"
HWADDR=00:11:22:33:44:55  #your mac address here
BOOTPROTO=dhcp
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_FAILURE_FATAL=no
PEERROUTES=yes
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_PRIVACY=no

 

Save and reboot

 

 

 

 

 
Was this article helpful? yes / no
Related articles Linux MD RAID optimisation
Article details
Article ID: 97
Category: Linux
Date added: 26-03-2017 11:41:47
Views: 56027
Rating (Votes): Article rated 4.7/5.0 (12)

 
« Go back

 
Powered by Help Desk Software HESK, in partnership with SysAid Technologies