Technical article 125485

How can I change the IP address of my server with a script?

OpenServer 6.0.0UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1UnixWare 7.1.2UnixWare 7.1.3UnixWare 7.1.4Open UNIX 8

Written · Last revised

Problem

Is there a way to change the IP address of my server automatically in a script?

Solution

Below is a script which can be used to accomplish this. Note that later versions of UnixWare7 may not have Netscape installed but the appropriate web server configuration file can be replaced as this serves as an example.

It is also recommended to run "ifconfig net0 down" prior to running the script, assuming that "net0" is the interface you intend to change.

It is also recommended to re-boot your server after making the change or alternatively follow the steps in TA117282, "How can I change the IP address of my UnixWare 7 system without rebooting?"

----------------------------------------------------------
#!/bin/sh
#1st argument is the current IP address
#2nd argument is is the new IP address
oldip=$1
newip=$2
HOSTS=/etc/hosts
INTERFACE=/etc/confnet.d/inet/interface
NSADMIN=/usr/ns-home/admserv/ns-admin.conf
cat $HOSTS | sed s/$oldip/$newip/g > /tmp/$$.hosts
cp $HOSTS $HOSTS.old
cp /tmp/$$.hosts $HOSTS
rm -f /tmp/$$.hosts
cat $INTERFACE | sed s/$oldip/$newip/g > /tmp/$$.interface
cp $INTERFACE $INTERFACE.old
cp /tmp/$$.interface $INTERFACE
rm -f /tmp/$$.interface
if [ -f $NSADMIN ]
then
cat $NSADMIN | sed s/$oldip/$newip/g > /tmp/$$.nsadmin
cp $NSADMIN $NSADMIN.old
cp /tmp/$$.nsadmin $NSADMIN
rm -f /tmp/$$.nsadmin
fi
----------------------------------------------------------

See also

TA117282, "How can I change the IP address of my UnixWare 7 system without rebooting?"

From the Xinuos technical article database, record 125485. Reproduced with permission. The original is at www.sco.com/ta/125485, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.