1、系统版本
root@SIMS_INIT[/root]#cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
2、改网卡配置文件名
root@SIMS_INIT[/etc/sysconfig/network-scripts]#mv ifcfg-ens33 ifcfg-eth0
root@SIMS_INIT[/etc/sysconfig/network-scripts]#mv ifcfg-ens34 ifcfg-eth1
root@SIMS_INIT[/etc/sysconfig/network-scripts]#ll
total 248
-rw-r--r-- 1 root root 113 Mar 13 10:52 ifcfg-eth0
-rw-r--r-- 1 root root 50 Mar 20 15:29 ifcfg-eth1
3、改配置文件内容name和device
root@SIMS_INIT[/etc/sysconfig/network-scripts]#vi ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.8.112
NETMASK=255.255.255.0
GATEWAY=192.168.8.1
USERCTL=no
root@SIMS_INIT[/etc/sysconfig/network-scripts]#vi ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=dhcp
USERCTL=no
我这边没有name,有name的话记得name也要改。
4、关闭centos7一致性网络设备命名法
root@SIMS_INIT[/root]#vi /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 rd.lvm.lv=vg00/lvroot rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
在GRUB_CMDLINE_LINUX选项后加上net.ifnames=0 biosdevname=0配置信息。
重新生成grub内核文件:
root@SIMS_INIT[/root]#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-0755899e8a05490093731f3fe8730d26
Found initrd image: /boot/initramfs-0-rescue-0755899e8a05490093731f3fe8730d26.img
done
5、添加设备规则配置文件
root@SIMS_INIT[/root]#vi /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3b:fb:79", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3b:fb:83", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
注意:
1、没有该文件新增即可。
2、注意mac地址和网卡名称的对应,可以通过ip addr命令获取。
6、重启主机生效
root@SIMS_INIT[/root]#reboot
7、确认生效配置
root@SIMS_INIT[/root]#ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3b:fb:79 brd ff:ff:ff:ff:ff:ff
inet 192.168.8.112/24 brd 192.168.8.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe3b:fb79/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3b:fb:83 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.46/24 brd 192.168.0.255 scope global dynamic eth1
valid_lft 86350sec preferred_lft 86350sec
inet6 fe80::20c:29ff:fe3b:fb83/64 scope link
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
link/ether 52:54:00:2a:e5:f0 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
link/ether 52:54:00:2a:e5:f0 brd ff:ff:ff:ff:ff:ff