Operating System - HP-UX
1828422 Members
3391 Online
109977 Solutions
New Discussion

netstat -rn, static route add script ..?

 
someone_4
Honored Contributor

netstat -rn, static route add script ..?

Hi everyone .. well let me start by telling everyone the issue here..

We have a server with a ton of static network routes and they get added and no one keeps track of what was added. The server had to be rebooted and of course the routes were not added back in.

I am aware that we can add routes in /etc/rc.configd/netconf .. and if netconf cant hold them add another start up script to add the routes.

But I was thinkig if there was a way to set up a scrit via cron that would do a netstat -rn .. get all the junk out and some how turn the netstat -rn into a route add script with the correct values and route add net statements that can be ran manualy if the box is rebooted.

~ Richard
5 REPLIES 5
harry d brown jr
Honored Contributor

Re: netstat -rn, static route add script ..?


Richard,

Write it in perl, but better yet, have people use the script to add entries into the netconf file, that way it survives the reboot.

live free or die
harry
Live Free or Die
Sridhar Bhaskarla
Honored Contributor

Re: netstat -rn, static route add script ..?

Richard,

You can write a script to capture netstat -rn output and dump the contents into a script using awk constructs.

While the subnets can be easily captured from netstat output, the challenge will be to determine the netmasks.

I would suggest not to work hard on getting it scripted. As a system administrator, you will need to keep track of what you do. While adding the route, make sure you also add it to a file so that you can simply excute the file after reboot. You can put it in the startup to automate during the boot. If you have many static routes, modifying netconf may be cumbersome.

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

Re: netstat -rn, static route add script ..?

Hi,

I agree with Sri. If I were going to write a script to help with this problem, I would write one that would go the opposite direction. I would check the netconf file against the output of netstat -rn and have it e-mail me if there were any routes in use that weren't in the netconf file. Then I could investigate them, add them if needed, and punish the offenders who added routes without updating netconf correctly.

JP
MANOJ SRIVASTAVA
Honored Contributor

Re: netstat -rn, static route add script ..?

Hi Richard


It is better to set it once in the netconf file as this is place where the sytem reads during startup . why do u want to do the work again and again .


You can look at this document which is comprehensive in this aspect :

http://www1.itrc.hp.com/service/cki/docDisplay.do?docId=200000049791567


Manoj Srivastav
Jeff Schussele
Honored Contributor

Re: netstat -rn, static route add script ..?

Hi Richard,

A variation on Harry's theme....write a wrapper around the route command that not only executes the actual route add/delete, but that adds/deletes the entries to/from the netconf file as well.
But, Sridhar & John are correct as well i.e. SAs are supposed to document *whatever* is changed on a system & a route change is certainly one of them.

My 2 cents,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!