首页 > 代码库 > centos7 change default interface name to eth0

centos7 change default interface name to eth0

#!/bin/bash

DEFAULTNAME=`ls /etc/sysconfig/network-scripts/ifcfg-en*`

EXPECTNAME=ifcfg-eth0

sed -i ‘s/DEVICE.*/DEVICE=eth0/g‘ $DEFAULTNAME

sed -i ‘s/ONBOOT.*/ONBOOT=yes/g‘ $DEFAULTNAME

mv $INITIALNAME /etc/sysconfig/network-scripts/$EXPECTNAME

sed -i ‘s/GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 /g‘ /etc/default/grub

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

echo "please reboot system"


centos7 change default interface name to eth0