ipo=`ip a show ens33 | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'| awk '{print $2,$NF}'`echo "参考的IP地址信息: $ipo"read -p "please input ip address:" ipsa1=`echo $ips | awk -F '.' '{print $1}'`a2=`echo $ips | awk -F '.' '{print $2}'`a3=`echo $ips | awk -F '.' '{print $3}'`a4=`echo $ips | awk -F '.' '{print $4}'`if [[ "$ips" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]];thenif [ $a1 -le 255 -a $a2 -le 255 -a $a3 -le 255 -a $a4 -lt 256 ];thenecho "input ip address is ok……"elseecho "input ip address is not ok……"exitfielseecho "input ip address is not ok……"exitfiread -p "please input ip netmask:" ipvu1=`echo $ipv | awk -F '.' '{print $1}'`u2=`echo $ipv | awk -F '.' '{print $2}'`u3=`echo $ipv | awk -F '.' '{print $3}'`u4=`echo $ipv | awk -F '.' '{print $4}'`if [[ "$ipv" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]];thenif [ $u1 -le 255 -a $u2 -le 255 -a $u3 -le 255 -a $u4 -lt 256 ];thenecho "input ip netmask is ok……"elseecho "input ip netmask is not ok……"exitfielseecho "input ip netmask is not ok……"exitfiread -p "plsase input ip gateway:" ipuo1=`echo $ipu | awk -F '.' '{print $1}'`o2=`echo $ipu | awk -F '.' '{print $2}'`o3=`echo $ipu | awk -F '.' '{print $3}'`o4=`echo $ipu | awk -F '.' '{print $4}'`if [[ "$ipu" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]];thenif [ $o1 -le 255 -a $o2 -le 255 -a $o3 -le 255 -a $o4 -lt 256 ];thenecho "input ip gateway is ok……"elseecho "input ip gateway is not ok……"exitfielseecho "input ip gateway is not ok……"exitfiread -p "please input ip dns:" ipmt1=`echo $ipm | awk -F '.' '{print $1}'`t2=`echo $ipm | awk -F '.' '{print $2}'`t3=`echo $ipm | awk -F '.' '{print $3}'`t4=`echo $ipm | awk -F '.' '{print $4}'`if [[ "$ipm" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]];thenif [ $t1 -le 255 -a $t2 -le 255 -a $t3 -le 255 -a $t4 -lt 256 ];thenecho "input ip dns is ok……"elseecho "input ip dns is not ok……"exitfielseecho "input ip dns is not ok……"exitfifile1=/etc/sysconfig/network-scripts/ifcfg-ens33cat >> $file1 <<eofIPADDR=$ipsNETMASK=$ipvGATEWAY=$ipuDNS1=$ipmeofsed -i '/^BOOTPROTO=/c BOOTPROTO="static"' $file1systemctl restart network