HP-UX: How Do I configure routing or add route?

by on October 29, 2005 · 4 comments· LAST UPDATED October 24, 2007

in , ,

You can use route command to configure routing. Syntax is as follows:
route add net {network-address} netmask {subnet} {router-address}

Let us assume your router address is 192.168.1.254 and network ID is 192.168.1.0/24, then you can type route command as follows:
# route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254

OR

To add a default route:
# route add default 192.168.1.254

Verify that (display) routing table is updated (display routing table):
# netstat -nr

Test it i.e. try to ping or send nslookup request:
# ping mycorp.com

To flush all routing entries use command [quite handy to clean your gordian knot ;)] :
# route -f

However if I reboot HPUX box then above routing entries gets removed. To pick up your setting upon each reboot your need to configure Routes in HPUX networking configuration file - /etc/rc.config.d/netconf. To add default router/gateway 192.168.1.254:
# vi /etc/rc.config.d/netconf

Add or modify following entries

ROUTE_DESTINATION[0]="default"
ROUTE_MASK[0]=""
ROUTE_GATEWAY[0]="192.168.1.254"
ROUTE_COUNT[0]="1"
ROUTE_ARGS[0]=""

Reboot HP-UX system/server to take effect
# shutdown -ry 0

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 pradeep July 11, 2007 at 12:01 pm

How to configure router command in linux

Reply

2 bob August 22, 2007 at 2:43 am

i like to subnet i am really good at it!!

Reply

3 soundar March 3, 2009 at 1:33 pm

hi will it work on sco unix as well, i tried but no luck, thank you for assisting on this.

Reply

4 Anuj April 13, 2012 at 7:57 am

In the command
# route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254
you havent mentioned the count 1 , while in the netconf entry you have.

Cheers

Reply

Leave a Comment

Tagged as: , , , , , , , ,

Previous post:

Next post: