一个简单修改服务器网络配置的脚本

#!/bin/bash
eth0=/etc/sysconfig/network-scripts/ifcfg-enp0s3
mac=`ifconfig -a | grep -o HWaddr.* | cut -c 8-24`

sed -i 's/IPADDR0=.*/IPADDR0=192.168.'$1'.'$2'/g' $eth0

if [ "$mac" != "" ]; then 
sed -i 's/HWADDR=.*/HWADDR='$mac'/g' $eth0
else 
echo 'mac is empty'
fi

if [ "$3" = "update"]; then  
sed -i 's/UUID=.*/UUID='`uuidgen`'/g' $eth0 
else
echo 'no update UUID' 
fi
service network restart
echo 'over'

执行./netconfig 11 22

猜你喜欢

转载自www.cnblogs.com/two-bees/p/11363666.html
0条评论
添加一条新回复