Saturday, September 23, 2017

Change default network name ens33 to eth0 in centos

# /etc/init.d/network status
Configured devices:
lo eth0
Currently active devices:
lo eth2
# dmesg | grep -i eth
eth0: registered as PCnet/PCI II 79C970A
udev: renamed network interface eth0 to eth2
eth2: link up
# ip -a
Option "-a" is unknown, try "ip -help".
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:2a:a7:b5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.112/24 brd 192.168.1.255 scope global eth2
    inet6 fe80::20c:29ff:fe2a:a7b5/64 scope link
       valid_lft forever preferred_lft forever

first we need to set static ip
#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

----------------------------------------------
# vi /etc/default/grub
net.ifnames=0 biosdevname=0 // add this line at end of the -GRUB_CMDLINE_LINUX="crashkernel=auto net.ifnames=0 biosdevname=0"

like

GRUB_CMDLINE_LINUX="rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet net.ifnames=0 biosdevname=0"


[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3f8cfec1c0f3435d9d5a2eb6afe11f2c
Found initrd image: /boot/initramfs-0-rescue-3f8cfec1c0f3435d9d5a2eb6afe11f2c.img
done
[root@localhost ~]## mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
# shutdown -r now
after reboot you can get that new interface name
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.108  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::7dd:8133:8570:e599  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:21:15:0f  txqueuelen 1000  (Ethernet)
        RX packets 4900  bytes 2776593 (2.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 816  bytes 80360 (78.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

No comments:

Post a Comment