CentOS7修改网卡名ensXX称为eth0

CentOS7.4 系统安装好后,默认网卡名称为为ensXX,如ens33,如果要修改为eth0开头,需要进行如下配置


1.查看原网卡名称:

[root@centos7 network-scripts]# ifconfig

ens33: flags=4163  mtu 1500

        inet 192.168.155.104  netmask 255.255.255.0  broadcast 192.168.155.255

        inet6 fe80::212a:c0fb:e179:7f1c  prefixlen 64  scopeid 0x20

        ether 00:0c:29:c4:34:bd  txqueuelen 1000  (Ethernet)

        RX packets 1465  bytes 129004 (125.9 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 802  bytes 104240 (101.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10

        loop  txqueuelen 1  (Local Loopback)

        RX packets 72  bytes 5720 (5.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 72  bytes 5720 (5.5 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:1a:02:e7  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@centos7 network-scripts]#


2.修改网卡信息

[root@centos7 ~]# cd /etc/sysconfig/network-scripts/
[root@centos7 network-scripts]# vi ifcfg-ens33

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=dhcp

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=eth0                   #name修改为eth0

UUID=048802a8-f20c-4c19-902a-e326b3a69686

#DEVICE=ens33

ONBOOT=yes


网卡配置文件名称改为 ifcfg-eth0 

[root@centos7 network-scripts]# mv ifcfg-ens33 ifcfg-eth0


3.修改grub配置

因 CentOS7 采用 grub2 引导,还需要对 grub2 进行修改,编辑 /etc/default/grub 配置文件,在 GRUB_CMDLINE_LINUX 这个参数后面加入 "net.ifnames=0 biosdevname=0"

[root@centos7 network-scripts]# vi /etc/default/grub

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=true

GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv

=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"

GRUB_DISABLE_RECOVERY="true"


用 grub2-mkconfig 命令重新生成GRUB配置并更新内核

[root@centos7 network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg

Generating grub configuration file ...

Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64

Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img

Found linux image: /boot/vmlinuz-0-rescue-c15c0efab776454daa1c4da36ec768f6

Found initrd image: /boot/initramfs-0-rescue-c15c0efab776454daa1c4da36ec768f6.img

done

[root@centos7 network-scripts]#


重启系统

[root@centos7 network-scripts]# reboot


4.验证网卡名

重启之后验证网卡名称:

[root@centos7 ~]# ifconfig

eth0: flags=4163  mtu 1500

        inet 192.168.155.104  netmask 255.255.255.0  broadcast 192.168.155.255

        inet6 fe80::8453:5a1:debb:b9d5  prefixlen 64  scopeid 0x20

        ether 00:0c:29:c4:34:bd  txqueuelen 1000  (Ethernet)

        RX packets 119  bytes 12471 (12.1 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 142  bytes 18721 (18.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10

        loop  txqueuelen 1  (Local Loopback)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@centos7 ~]#

你可能感兴趣的:(CentOS7修改网卡名ensXX称为eth0)