Monday, October 12, 2015

How to change network interface name from Enp0s3 to Eth0 on CentOS 7

 CentOS 7 Change Network Interface Name From Enp0s3 To Eth0

CentOS 7 Change Network Interface Name

Step1
# issue the ifconfig command to check the current network interface information, type:
# yum install net-tools









[root@localhost Desktop]$sudo ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.42.129  netmask 255.255.255.0  broadcast 192.168.42.255
inet6 fe80::20c:29ff:fec7:25ae  prefixlen 64  scopeid 0x20<link>
ether 00:0c:29:c7:25:ae  txqueuelen 1000  (Ethernet)
RX packets 200948  bytes 253071365 (241.3 MiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 56043  bytes 3420351 (3.2 MiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Step2
# edit “/etc/sysconfig/grub” configuration file using “vim” command:
before:






[root@localhost Desktop]$sudo vim /etc/sysconfig/grub
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

then searching for “GRUB_CMDLINE_LINUX” line  and appending the following content “net.ifnames=0 biosdevname=0“, just like the below:


GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb quiet net.ifnames=0 biosdevname=0"

Step3
# Using “grub2-mkconfig” command to re-generate a new grub configuration file, type:
>








[root@localhost Desktop]$sudo grub2-mkconfig  -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Warning: Please don't use old title `CentOS Linux, with Linux 3.10.0-123.el7.x86_64' for GRUB_DEFAULT, use `Advanced options for CentOS Linux CentOS Linux, with Linux 3.10.0-123.el7.x86_64' (for versions before 2.00) or `gnulinux-advanced-dbedd8fa-5d86-4ea0-8551-8444a48cd44f nulinux-3.10.0-123.el7.x86_64-advanced-dbedd8fa-5d86-4ea0-8551-8444a48cd44f' (for 2.00 or later)
Found linux image: /boot/vmlinuz-0-rescue-3303e35a730a41e3b4e99b544acea205
Found initrd image: /boot/initramfs-0-rescue-3303e35a730a41e3b4e99b544acea205.img
done

Step4
#   Rename “Enp” network file using”mv”command, type:

$sudo mv /etc/sysconfig/network-scripts/ifcfg-enp0s3  /etc/sysconfig/network-scripts/ifcfg-eth0

Step5
# Edit “/etc/sysconfig/network-scripts/ifcfg-eth0 ” configuration file and set the value of “Name” field to “eth0″.


















# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
<strong>NAME=eth0</strong>
UUID=5ae10208-855b-41af-99e7-0673d3792d15
ONBOOT=yes
HWADDR=00:0C:29:C7:25:AE
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
Step6
# reboot system, after rebooting system, using “ifconfig” command check network interface information again.









[root@localhost Desktop]# ifconfig
eth0: flags=4163 UP,BROADCAST,RUNNING,MULTICAST  mtu 1500
inet 192.168.42.129  netmask 255.255.255.0  broadcast 192.168.42.255
inet6 fe80::20c:29ff:fec7:25ae  prefixlen 64  scopeid 0x20
ether 00:0c:29:c7:25:ae  txqueuelen 1000  (Ethernet)
RX packets 49  bytes 5285 (5.1 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 76  bytes 8540 (8.3 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
done….

No comments:

Post a Comment