设置网卡1: > /etc/sysconfig/network-scripts/ifcfg-ens33 echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo NAME=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo DEVICE=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo IPADDR=192.168.2.141 >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo #GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo #DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens33 mac=`ifconfig ens33|grep ether|awk '{print $2}'` sed -i '/BOOTPROTO/aHWADDR='$mac'' /etc/sysconfig/network-scripts/ifcfg-ens33 more /etc/sysconfig/network-scripts/ifcfg-ens33 mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0 设置网卡2: > /etc/sysconfig/network-scripts/ifcfg-ens34 echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo NAME=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo DEVICE=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo #IPADDR=192.168.2.139 >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo #PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo #GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens34 echo DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens34 mac=`ifconfig ens34|grep ether|awk '{print $2}'` sed -i '/BOOTPROTO/aHWADDR='$mac'' /etc/sysconfig/network-scripts/ifcfg-ens34 more ifcfg-ens34 mv /etc/sysconfig/network-scripts/ifcfg-ens34 /etc/sysconfig/network-scripts/ifcfg-eth1 设置网卡唯一属性并重启生效 sed -i 's/rhgb/net.ifnames=0 biosdevname=0 &/' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg reboot