1 #/bin/bash 2 NETPWD='/etc/sysconfig/network-scripts/' 3 read -p "please enten net num(1,2,3,4) : " NUM 4 EM="$NETPWD"ifcfg-em$NUM 5 read -p "please enten ip last num : " NUM1 6 sed -i 's/ONBOOT=no/ONBOOT=yes/' $EM 7 sed -i 's/ONBOOT="yes"/ONBOOT="no"/' /etc/sysconfig/network-scripts/ifcfg-em1 8 sed -i 's/dhcp/static/' $EM 9 cat >> $EM << EOF 10 IPADDR=10.1.0.$NUM1 11 GATEWAY=10.1.0.254 12 NETMASK=255.255.255.0 13 EOF 14 #systemctl restart network.service 15 /etc/init.d/network restart 16 echo doubidou | passwd --stdin root