Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove 2nd default gateway from ODM

Status
Not open for further replies.

mpezeur

MIS
Nov 7, 2002
123
US
Noticed from attribs of inet0 that I have two default gateways defined, one of them is incorrect, which explains why when the AIX 5.2 server reboots it can't ping hosts on other subnets. lsattr -EHl inet0 lists the route parameter twice, both set to true, with the second parameter having the incorrect setting. odmget also lists the incorrect route. What's the best way of removing the incorrect route ? This is a production server that I can't reboot during the day, but WILL be rebooting it tonight for monthly maintenance.
 
It is not unusual having more than one route attribute on inet0, but if you have two route attributes with value net,,0,<ip_address> I'd go with either

route -f
chdev -l inet0 -a route=0,<ip_address_of_def_gw>
(wouldn't do that in full production mode but you have a maintenance window tonight so,...)

or: Try to remove the faulty route attribute with odmdelete - may be kind of tricky to get the right one:

odmdelete -o CuAt -q "name=inet0 and attribute=route and value='net,,0,wrong_ip_address_here'"

you should get a reply: odmdelete: 1 object(s) deleted

It may be wise to run that query thru odmget first to make sure you are picking up just 1 stanza and that it is the one you want out.

You also might want to make sure you have a recent mksysb - better safe than sorry...


HTH,

p5wizard
 
I used the odmget and odmdelete, as you said, and that fixed it. lsattr -EHl inet0 now shows just the one correct default route.

thanks for the help!
 
HI,

I have created a script that does just that - removes any redundant default gateways.Works well for me.
=============================================
#!/bin/ksh
#
# Version 1.0
# August 30, 2005
#
#The script cleans ODM from redundant routs :
#1.Get the real default gateway (if exists) from lsip.sh .If there is no gateway found - just quit with message.
#2.Check for other gateways and remove them from ODM.
#3.If any routes were bad and have been removed - do the following:
# -flush all gateways
# -run bosboot
# -recreate the good default gateway

LOG=/tmp/cleanroute.log
HOSTNAME=`hostname`

#Check if my host is available.If not - force reboot at the end of the script
ping -c 1 $HOSTNAME >/dev/null 2>&1
if [[ $? != 0 ]] ;then
echo "My host $HOSTNAME is not pingable." |tee -a $LOG
exit 1
fi

MYADDRESS=`traceroute $HOSTNAME 2>/dev/null |awk '/source/ && ! /trying/ {print $4}'`
MYENT=`netstat -rn|grep $MYADDRESS|awk '! /lo0|pp0/ {print substr($6,3)}'|sort -u`

echo "============================================================" |tee -a $LOG
echo `date` >> $LOG
#Dsplay the orinal routing
echo "\ninet0 :" |tee -a $LOG
echo "`lsattr -El inet0|grep Route`" |tee -a $LOG
echo "\nnestat :" |tee -a $LOG
echo `netstat -rn|grep default`|tee -a $LOG
echo "-------------------------------------------"|tee -a $LOG

#establish the real gateway address
for EN in `lsdev -Cs pci| awk '/ent/ { print $1 }'|cut -c 1,2,4`;do
DEFAULT=`mktcpip -S $EN 2>&1|awk -F: '$0 !~ /host/ {print $7 }'`
if [[ -n $DEFAULT ]] ;then #just get the first gateway occurance and carry on
break
fi
done

if [[ -z $DEFAULT ]] ;then
echo "No default gateways were found !"
exit 1
fi

for DEFAULT1 in `netstat -rn|grep -v $DEFAULT|awk '/UGc/ {print $2}'` ;do #it's a gateway,but not a default one
if [[ $DEFAULT1 != $DEFAULT ]] ;then #if it's a bad gateway - remove it
VALUE=`odmget CuAt|grep -w $DEFAULT1|awk -F'"' '{print $2}'`
odmdelete -q "name=inet0 and value='$VALUE'" -o CuAt
BAD=1
fi
done

if [[ $BAD != 1 ]] ;then
echo "No bad routes were discovered." |tee -a $LOG #exit if nothing was changed
exit 0
fi

route -n -f |tee -a $LOG #flash all routes
echo "\nNow running bosboot.This may take a minute ..."
bosboot -a -d `lspv | grep rootvg | awk '{print $1}'|head -1`|tee -a $LOG #create bosboot
mktcpip -h $HOSTNAME -a $MYADDRESS -g $DEFAULT -i en$MYENT |tee -a $LOG #restore the good gateway

#Dsplay the new routing
echo "\ninet0 :" |tee -a $LOG
echo "`lsattr -El inet0|grep Route`" |tee -a $LOG
echo "\nnestat :" |tee -a $LOG
echo `netstat -rn|grep default`|tee -a $LOG
echo "-------------------------------------------"|tee -a $LOG



Long live king Moshiach !
 
Hi

Why you are using so stupid methods like odmdelete ? ;->
smitty route -> remove a route ->

Destination TYPE net +
* DESTINATION Address [default]
(dotted decimal or symbolic name)
* Default GATEWAY Address [your wrong IP-Adress]
(dotted decimal or symbolic name)
Network MASK (hexadecimal or dotted decimal) []


 
I had to use odmdelete because smitty route does the same thing as the command route, aka route delete, which only clears the route while that server is up. I know, I tried several times.

Anyway, I rebooted the server Wednesday night, and even though I ran odmdelete earlier and confirmed through lsattr -EHl inet0 and odmget that the wrong gateway was gone, the incorrect gateway showed up again after reboot. I then ran the odmdelete, lsattr and finally smitty tcpip and then rebooted, and the incorrect gateway did not re-appear after reboot. Won't be rebooting this production server again until next month, but the problem looks to have been resolved since the last reboot
 
Also, I wouldn't call it a stupid method, it's just a low-level command that *can* be used to clean up if things get messed up too much for the high level commands to deal with...

You want to make double sure that the query you give to odmdelete makes it delete exactly what you want and nothing more. I believe I stressed that point to mpezeur enough?


HTH,

p5wizard
 
p5, after I ran odmdelete I ran odmget and lsattr -EHl ent0, and each time the stanza for the incorrect gateway were gone, with the command outputting only the correct router.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top