How to configure IP for many computer with of by shell programing ?
ex: add ip, remove ip.
thanks
How to configure IP for many computer with of by shell programing ?
ex: add ip, remove ip.
thanks
If they're on a lan networ, I think your router will assign IP's using DHCP automatically, unless you go to each computer and program a static IP. If you want static IP's, you'll have to go to each computer and type in ifconfig plus some other info that I don't remember. Do a "man ifconfig". It's less confusing than it looks.
You can't do through network but to reduce ur work.You can do as below
create a file named hosts and make entries as below [Replace the hostname and IP as per yours]
#vi hosts.txt
hosta 10.1.1.18
hostb 10.1.1.19
hostc 10.1.1.20
<Format should be hostname IPADDRESS>
Copy the hosts files you created and below script to a pendrive. Change the permission of ip.sh to 755.
#vi ip.sh
MYHOST=`hostname`
IP=`grep $MYHOST hosts|awk '{print $2}'`
echo -e "IPADDR=$IP \n NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "GATEWAY=10.1.1.1" >> /etc/sysconfig/network
/etc/init.d/network restart
Mount to the hosts individually and execute the script.
#mount /dev/sdx /mnt [x is the drive ipdentified by your host.use fdisk -l]
#cd /mnt;./ip.sh
Hope this helps you.
The best way to assign ip to many computers is via DHCP server. DHCP protocol is designed for this purpose only.
Run a dhcp server in one of the system in the network and dhclient in all other systems.
If you are bothered about getting the same ip always for every system, this can also be done via dhcp server/client configuration file .
Hope this helps !!
Manish Gupta
Last edited by Nishu; 11-16-2011 at 05:47 AM.
Bookmarks