Originally posted by: SystemAdmin
This is only 4 years late, but encase others come here looking for an answer.
One method to accomplish this is to change the source network adapter to be 'down' in the ODM.
# chdev -l en0 -a state='down' '-P'
You can then setup a first boot script or some rc.local script (setup in the inittab before rc.tcpip). Below is a sample of a script I wrote to boot a DR LPAR with a different IP if it's on the production vlan. In our environment the production vlans are 3 digits and the test bubble vlans are 4 digits.
Note that the last thing the scripts does is to reset the adapter to 'down' in the ODM.
The adapter has to be down because when rc.boot calls cfgmgr the ODM setting are used to configure the adapter and if it's up you can get a duplicate IP error.
If you're running on dedicated hardware you can key off the serial number. and set the IP via a case statement.
Good luck with this and I hope the script helps,
Allan
#! /usr/bin/ksh -x
export PATH=/usr/bin:/etc:/usr/sbin:/sbin:/usr/ccs/bin:.
uname -L | read ID LPAR
HOSTNAME="$(hostname -s | perl -pe 's/.*_//; s/-.*//;' )"
DNS="-n172.30.105.61 -dfossil.com"
GW="$( lsattr -El inet0 -a route -F value | awk -F, '{print $NF}' )"
IP="$( grep -wi "${HOSTNAME}" /etc/hosts | egrep -v "dr_|-dr" | awk '{print $1}' | cut -f1-3 -d\. )"
for ENT in $( lsdev -Cc adapter | awk '/^ent/{print $1}' )
do
EN="$( echo ${ENT} | sed 's/t//' )"
IP="$( lsattr -El ${EN} -a netaddr -F value | grep ^${IP:-'172'} )"
[
-n ${IP} ] && break
done
NETMASK="$( lsattr -El ${EN} -a netmask -F value )"
-
-
If this is a test dr lpar then check if we are in a bubble. (VLANS 2248 and 2101)
if echo ${LPAR} | grep -qi ^drtst
then
#-- Isolate from DNS in Norm because we can't reach it in Prod so we don't use it
mv /etc/resolv.conf /etc/resolv.drtst
#-- Get the etherchannel adapters as these are the ones that we'll be configuring
entstat -d ${ENT} > /tmp/${ENT}.out
#-- Check to see if there's a 3 digit vlan if so then assume we're on the production network not a bubble
PROD=$( perl -ne 'chomp;if(/port\s+vlan\s+id:\s+(\d+.*)|vlan\s+tag\s+ids:\s(\d+.*)/i){print "$1 "}' /tmp/${ENT}.out |
perl -ne 'if( /\b\d\d\d\b/ ){print "1"} else {print "0"}' )
if (( PROD ))
then
#-- Ok so we in a TEST DR LPAR on the production network - RESET EVERYTHING
IP="$( grep -wi "${HOSTNAME}-dr" /etc/hosts | awk '{print $1}' )"
DNS=""
#-- Make sure cron and TSM are off
perl -i -pe 'if( /^(cron|dsm|errreporter|db|ora)/ ){s/^/:/}' /etc/inittab
else
perl -i -pe 'if( /^(cron|dsm|errreporter|db|ora|rcnfs)/ ){s/^/:/}' /etc/inittab
fi
telinit q
mkdev -l iocp0
chdev -l iocp0 -P -a autoconfig='available'
fi
-
-
Setup the network based on the discovered environment
/usr/sbin/mktcpip -h"${HOSTNAME}" -a"${IP:-8.8.8.8}" -m"${NETMASK:-255.255.255.0}" -i"${EN}" ${DNS} -g"${GW}" -A'no' -t'N/A'
chdev -l ${EN} -a state='up' '-P'
( sleep 300 && startsrc -s sshd ) &
( sleep 300 && chdev -l ${EN} -a state='down' '-P' ) &