eth0=/etc/sysconfig/network-scripts/ifcfg-enp0s3
mac=`ifconfig -a | grep -o HWaddr.* | cut -c 8-24`ui
echo "$1"
echo "$2"
echo "$3"
echo "$4"
echo "$5"rest
if [ "$1" = "" ] || [ "$2" = "" ]; then echo 'exit'; exit 3; ficode
sed -i 's/IPADDR0=.*/IPADDR0=192.168.'$1'.'$2'/g' $eth0blog
if [ "$mac" != "" ]; then
sed -i 's/HWADDR=.*/HWADDR='$mac'/g' $eth0
else
echo 'mac is empty'
fiip
if [ "$3" != "" ] && [ "$4" != "" ]; then
sed -i 's/GATEWAY0=.*/GATEWAY0=192.168.'$3'.'$4'/g' $eth0
else
echo 'no update GATEWAY'
fiit
if [ "$5" = "update"]; then
sed -i 's/UUID=.*/UUID='`uuidgen`'/g' $eth0
else
echo 'no update UUID'
ficlass
echo 'over'
service network restartsed
執行./netconfig 11 22便可date