CentOS 7.2修改网卡名称
#!/bin/bash #Centos7.2修改网卡名称ens33为eth0 #2017/05/19 if [ -f /etc/sysconfig/grub ];then cd cp /etc/sysconfig/grub ./grub.conf sed -i '/GRUB_CMDLINE_LINUX/s/"$/ net.ifnames=0 biosdevname=0&/' ./grub.conf cat grub.conf > /etc/sysconfig/grub rm -f grub.conf fi if [ $? == 0 ];then grub2-mkconfig -o /boot/grub2/grub.cfg else exit 1 fi sleep 1 mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0 if [ -f /etc/sysconfig/network-scripts/ifcfg-eth0 ];then sed -i '/^NAME/s/.*/NAME=eth0/;/^DEVICE/s/.*/DEVICE=eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0 else exit 1 fi [ $? == 0 ] && reboot || exit 1