码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 7.2修改网卡名称

时间:2017-05-19 17:43:35      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:logs   div   sysconf   pre   $?   scripts   name   conf   names   

#!/bin/bash
#Centos7.2修改网卡名称ens33为eth0
#2017/05/19


if [ -f /etc/sysconfig/grub ];then
	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

  

CentOS 7.2修改网卡名称

标签:logs   div   sysconf   pre   $?   scripts   name   conf   names   

原文地址:http://www.cnblogs.com/Eivll0m/p/6879430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!