SUMMARY: Changing IP address via script

From: Michael Wright (mdwrigh@InetGate1.Wal-Mart.Com)
Date: Fri Jul 25 1997 - 10:28:15 CDT


Here is the summary I promised regarding changing the IP address on a
SUN via a script from a remote machine. Sorry for the delayed response.

The steps I took to accomplish the change were:

Shutdown network interface using ifconfig
Change IP address in hosts file
Change network class number in /etc/inet/netmasks
Delete old default route
Restart network interface
Add new default route
Modify /etc/resolv.conf to reflect new changes

The host name, domain name, and fourth octet of IP address remained the
same.
NIS and licensed products were not a factor.

Below is my original message and the responses I received from:
Thomas.Jordan@east.sun.com
Sanjaya.Srivastava@ebay.sun.com
seanw@amgen.com
rogerio@bvl.pt
jim@telecnnct.com
Jurilla.Bruce@jmco-asia.com
cmarble@orion.ac.hmc.edu
gkuma@sunwaycol.maxisnet.com.my
vogelke@c17.wpafb.af.mil
karen@websvr.fmr.com
bern@uni-trier.de

Thanks to everyone who responded.

...Mike

> -----Original Message-----
> Hello Sun Managers, I will soon be changing the IP addresses on my Sun
> boxes by running a script on one box (not a sun) that remotely
> executes
> a script on the Sun box. The files I expect to be affected are:
>
> /etc/defaultrouter
> /etc/inethosts
> /etc/inet/netmasks
> /etcresolv.conf (if nameserver changes)
>
> Here's my questions:
>
> 1) Are there any other files besides the ones I've listed, which
> should
> be considered?
> 2) Is there anyway to make an IP address change effective without
> rebooting?
> 3) Does anyone already have a script that performs this task?
>
> Thanks in advance for your help, I will provide a summary to the list.
>
> ...Mike

############ From: Thomas.Jordan@east.sun.com ##################
>
> Hello Sun Managers, I will soon be changing the IP addresses on my Sun
> boxes by running a script on one box (not a sun) that remotely executes
> a script on the Sun box. The files I expect to be affected are:
>
> /etc/defaultrouter
> /etc/inethosts
> /etc/inet/netmasks
> /etcresolv.conf (if nameserver changes)

you can change it on the fly with
ifconfig le0 127.0.0.1 netmask 255.255.255.0
and then you need to change the route
route delete default {route}
route add default {newroute} 1

of course, substitute le0 with your interface and 127.0.0.1 with the ip
address.
You obviously need to put this into a script b/c as soon as you run the
ip
change, you will not be able to talk to the machine.
I've run something similar to this that changed all of this stuff.

I'm attaching that script with the names and ip changed to fake stuff.
We automount home dirs, so I put a + in my home dir and rsh this to
every
machine. It changed the routers, ips, yp stuff, but not on the fly.

Tom
########## From: Sanjaya.Srivastava@ebay.sun.com ################
If the name of the machine changes conder changing /etc/net/ti*/hosts
also.

you could execute

ifconfig le0 down
ifconfig le0 inet xxx.yyy.zzz.nnn
ifconfig le0 up

Remember to copy the script to local workstation before doing a ifconfig
le0
down 'cause the workstation will not be able to access the netrwork if
it le0
is down. This way you could avoid rebooting.

...Sanjay

############ From: seanw@amgen.com ####################
Hi Michael. You'll also need to edit the following files:
/etc/hostname.xxN file(s), where xxN is the interface name (for example
le0)
/etc/nodename
/etc/net/*/hosts

########### From: rogerio@bvl.pt #########################
Have a look at a "boot script" invoked by rc2 (?).
if [ $SECONDARY -eq 0 ]; then
        IM_SECONDARY=1
       echo "Configuring network interface as $Sec_Services_Host"
        interface_name=`grep -v \^\# ./host_interfaces | grep SECONDARY
|
awk '{print $4}' `
        echo $Sec_Services_Host
        ifconfig $interface_name up -trailers $Sec_Services_Host plumb
        echo "Mounting shared partitions..."
        partitions=`grep -v \^\# ./mounts.shared | awk '{print $1}' `
....
deleted lines
.....
else
using file host_interfaces
# PRIMARY SECONDARY SECONDARY
# Hostname Hostname Interface
#
#siib siid hme0:1
#siic siie le0:1
#
PRIMARY s2000 siib le0:1
SECONDARY s2000 siic le0:2

hope this is of some help
Best regards,
Rogerio Rocha

############### From: jim@telecnnct.com ###############
> 1) Are there any other files besides the ones I've listed, which should
> be considered?

If you're running "named" (DNS) you'll need to update the DNS database
on the DNS server's /var/named/<files> and change the "serial" line when
it applies, then "kill -HUP" the named PID...

Your NIS Server "hosts" file must be updated every time you change a
host...

> 2) Is there anyway to make an IP address change effective without
> rebooting?

ifconfig <port> ...

################ From: Jurilla.Bruce@jmco-asia.com ################
Include also in your list:

/etc/hostname.X
/etc/nodename

that is, if you are not maintaining the same alias.

################ From: cmarble@orion.ac.hmc.edu ################
> 1) Are there any other files besides the ones I've listed, which should
> be considered?

/etc/hostname.le0
/etc/hostname.hme0

> 2) Is there anyway to make an IP address change effective without
> rebooting?

Unplumb the interface, then plumb it and put in what you want.
You'll be using ifconfig for this.
################# From: gkuma@sunwaycol.maxisnet.com.my ##############
After changing the files,
you can run the :
'ifconfig' command to change the ip and netmask without a need to reboot
' route add ' command to add default router without rebooting the sys.
Sorry I've forgotten the parameters.....and too busy to look it up for
u.

Regards,
Kumar
############### From: vogelke@c17.wpafb.af.mil #####################
M> Is there anyway to make an IP address change effective without
M> rebooting? Does anyone already have a script that performs this task?

   You'll really have to reboot to make this work, and I wouldn't trust
any
   script that tried to do this for me.
############### From: karen@websvr.fmr.com #####################
I am about to embark on the same project, but I'm afraid I don't have a
script for you. Here are a couple of other things to look for though:

- Any applications which might be licensed by IP address
- Any Sybase/Oracle or other DBMSs which have IP addresses as part of
their configuration
- (God forbid) - Any hardcoded IP addresses in things like:
        .rhosts files
        .netrc files
        /etc/hosts.equiv
        
You probably COULD make the change without a reboot, but make sure you
can get to the system physcially JUST in case. You'd have to ifconfig
the interfaces down, then up again with the new IP, netmask, broadcast
addresses. You'd also have to update your routing table.

I'd be interested to see what other responses you get.

Karen

################ From: bern@uni-trier.de ######################
> 1) Are there any other files besides the ones I've listed, which should
> be considered?

Yes - because IP#s, as well as Hostnames, are ubiquitous in Config
Files, you need to check *Loads* of Files to ensure that all the
installed S/W will stay operational. (If you use NIS, just think of
the Netmasks in your NIS Server's /var/yp/securenets !)

For an older Summary on that Question, see:
ftp://ftp.informatik.uni-trier.de/pub/Users-CTVD/bern/sunos/ChangeIP

> 2) Is there anyway to make an IP address change effective without
> rebooting?

As far as the OS is concerned - yes (just run the appropriate ifconfig
Commands). Whether you can reconfigure whatever other Daemons on the
Fly (assumed that they needed Config Changes) depends pretty much on
what you run ...

> 3) Does anyone already have a script that performs this task?

Three Words: Don't trust any.

Regards,
J. Bern
###############################################################
------------------------------------------------------------------------
--------------------
Michael Wright Information Services Division
Wal-Mart Home Office Store Systems Engineering
702 SW 8th St. mdwrigh@Wal-Mart.Com
Bentonville, AR 72716 Voice: (501) 277-5363
------------------------------------------------------------------------
--------------------



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:59 CDT