vim ip.sh
#!/bin/bash
read -p "eth:" e
read -p "ip:" ip1
read -p "netmask:" mask1
read -p "route:" route1
read -p "dns:" dns1
mac=$(ifconfig $e | grep "HWaddr" | awk '{print $5}')
path1="/etc/sysconfig/network-scripts/ifcfg-"
echo "DEVICE=eth$e" > $path1$e
echo "HWADDR=$mac" >> $path1$e
echo "TYPE=Ethernet" >> $path1$e
echo "ONBOOT=yes" >> $path1$e
echo "NM_CONTROLLED=yes" >> $path1$e
echo "BOOTPROTO=static" >> $path1$e
echo "IPADDR=$ip1" >> $path1$e
echo "NETMASK=$mask1" >> $path1$e
echo "GATEWAY=$route1" >> $path1$e
echo "DNS1=$dns1" >> $path1$e
service network restart