Centos7修改默认网卡名

 en命名方式修改

enp8s0=`ip a |grep ether | awk 'NR==1{print $2}'`
enp9s0=`ip a |grep ether | awk 'NR==2{print $2}'`

sed -i 's/rhgb/rhgb net.ifnames=0 biosdevname=0/g' /etc/default/grub

grub2-mkconfig -o /boot/grub2/grub.cfg

cat << EOF > /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$enp8s0", ATTR{type}=="1", KERNEL=="eth*", NAME="enp8s0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$enp9s0", ATTR{type}=="1", KERNEL=="eth*", NAME="enp9s0"
EOF

mv /etc/sysconfig/network-scripts/ifcfg-enp8s0 /etc/sysconfig/network-scripts/ifcfg-enp9s0
mv /etc/sysconfig/network-scripts/ifcfg-enp7s0 /etc/sysconfig/network-scripts/ifcfg-enp8s0

sed -i 's/enp7s0/enp8s0/g' /etc/sysconfig/network-scripts/ifcfg-enp8s0
sed -i 's/enp8s0/enp9s0/g' /etc/sysconfig/network-scripts/ifcfg-enp9s0

history -c
reboot

eth命名方式修改

+----------------------+
|    安装系统时修改      |
+----------------------+
按tab键,加入
net.ifnames=0  biosdevname=0

+----------------------+
|    修改配置文件        |
+----------------------+
vim /etc/default/grub 
GRUB_CMDLINE_LINUX="... net.ifnames=0 biosdevname=0"

grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

 

上一篇:Nginx安装配置


下一篇:序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用