[关闭]
@songlaf 2016-05-29T04:18:57.000000Z 字数 836 阅读 581

Centos克隆主机IP地址的设置

Linux

!/bin/bash

if [ $# != 2 ]
then
echo "please input ip address && host name"
exit 0
fi

newaddress=grep '1\"$' /etc/udev/rules.d/70-persistent-net.rules | awk '{ print $4 }'|awk -F '\"' '{ print $2 }'
sed -i '7,8d' /etc/udev/rules.d/70-persistent-net.rules

echo -e "DEVICE=eth1\nBOOTPROTO=none\nHWADDR=1\nNETMASK=255.255.255.0\nDNS1=192.168.18.2\nGATEWAY=192.168.18.2\nDNS1=202.96.209.5\nUSERCTL=no" > /etc/sysconfig/network-scripts/ifcfg-eth1
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
echo "change mac address finished"

tempstring=grep 'IPADDR' /etc/sysconfig/network-scripts/ifcfg-eth1

rm -f /etc/hosts
echo -e "127.0.0.1 2\n2" > /etc/hosts

sed -i '2,3d' /etc/sysconfig/network
sed -i "aHOSTNAME=$2" /etc/sysconfig/network

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注