1.重命名网卡名称

[root@localhost ~]# cd  /etc/sysconfig/network-scripts/    #进入网卡目录

[root@localhost ~]# mv ifcfg-ens33  ifcfg-eth0   #重命名网卡名称


2.编辑网卡信息

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0   #编辑网卡信息

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=none

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=ens33     ##修改为eth0

UUID=3be6ead6-a6a9-4f79-b299-f357c401316f

DEVICE=ens33   ##修改为eth0

ONBOOT=yes

IPADDR=192.168.1.20

PREFIX=24

GATEWAY=192.168.1.1

DNS1=114.114.114.114

IPV6_PRIVACY=no



3.修改GRUB内核信息


[root@localhost ~]# vim /etc/sysconfig/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 rhgb net.ifnames=0 biosdevname=0 quiet"

GRUB_DISABLE_RECOVERY="true"


4.生成启动菜单


[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg   #生成启动菜单

Generating grub configuration file ...

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

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

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

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

done


5.重启验证是否修改成功


[root@localhost ~]# reboot    #必须重启系统生效

[root@localhost ~]# yum -y install net-tools    #默认centos7不支持ifconfig 需要看装net-tools包

[root@localhost ~]# ifconfig eth0    #查看网卡信息

eth0: flags=4163  mtu 1500

        inet 192.168.1.20  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::dd83:5ea6:e9d6:931  prefixlen 64  scopeid 0x20

        ether 00:0c:29:76:e9:f9  txqueuelen 1000  (Ethernet)

        RX packets 9815  bytes 14080741 (13.4 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 5732  bytes 372251 (363.5 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0