IDC small rookie one, non-trained. There are often customers with CentOS servers that need to allocate 15 IPs or even 30 IPs. Each time a manual assignment was cumbersome, it took a day to learn the shell script and write the script.
#!/bin/bash
Read-p "The IP numbers:" num
while [[$num-GT 0]]
Do
Read-p "Please enter IP address:" IPAddr
Touch/etc/sysconfig/network-scripts/ifcfg-eth0: $num
Ncf=/etc/sysconfig/network-scripts/ifcfg-eth0: $num
echo Device=eth0: $num > $NCF
echo type=ethernet >> $NCF
echo bootproto=static >> $NCF
echo ipaddr= $ipaddr >> $NCF
echo netmask=255.255.255.192 >> $NCF
echo Onboot=yes >> $NCF
num= ' expr $num-1 '
Done
Service Network restart
As the company's mask is 255.255.255.192 so direct use, as long as the input needs to allocate the number of IP and IP address.
After writing this script will come in handy immediately, but still think the manual input IP is too troublesome, next time to write a direct from another file to extract the IP address of the script bar.
Write the first script yourself. Full of accomplishment < () >
CentOS assigns IP script--The first shell script written