Operating System - HP-UX
1847895 Members
2475 Online
104021 Solutions
New Discussion

Changing IP's via scripts

 
SOLVED
Go to solution
Jim Lynn_1
Occasional Advisor

Changing IP's via scripts

We are changing out our networks and I need a script that will change the IP address and netmask then reboot the machine after the change. Anybody done this before ?
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: Changing IP's via scripts

Hi Jim,

The best way is to update your /etc/rc.config.d/netconf file.

#cp /etc/rc.config.d/netconf /etc/rc.config.d/netconf.old
#vi /etc/rc.config.d/netconf

Make changes to reflect your new IP address and netmasks.

#shutdown -h now

Let your network people change the configuration and bring up the server. It should come up with the configuration you specified in netconf file.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
ITeam
Super Advisor

Re: Changing IP's via scripts

Jim,

Dont copy the netconf file to netconf.old in the same directory. Copy it somewhere else like /tmp instead. I did exactly the same thing once and as the system came back up, the netconf file was read first and then the netconf.old file was read, putting all of the network settings back to what I had changed them from. Took me a while to realise what was happening.
Pete Randall
Outstanding Contributor
Solution

Re: Changing IP's via scripts

For a script, you might want to look at /sbin/set_parms. Do a man on set_parms.

Pete

Pete
Paul Sperry
Honored Contributor

Re: Changing IP's via scripts

I did this to about 100 workstations when we changed our network

you will need to edit the following files.

/etc/rc.config.d/netconf
/etc/hosts
/var/adm/inetd.sec

edit the files to reflect the new IPs and netmask. shutdown the systems the put then on the new network and they should come up fine
Sridhar Bhaskarla
Honored Contributor

Re: Changing IP's via scripts

/sbin/init.d/net script reads directly from /etc/rc.config.d/netconf. But most of the other /sbin/init.d/ files run /etc/rc.config script that in turns runs each configuration file under /etc/rc.config.d/ directory.

So, though it doesn't affect here, I agree that it is a good practice not to keep the backup files in /etc/rc.config.d directory.

Good point Alpha Numeric Systems.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try