Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Networking
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a static route for a range of IPs

crsk1234
Visitor

Adding a static route for a range of IPs

Hi

For adding static route hpux, I know we have to edit /etc/rc.config.d/netconf file & start the net service /sbin/inet.d/net start.
 
Eg:

ROUTE_DESTINATION[13]="host 10.14.252.222"
ROUTE_GATEWAY[13]=10.253.240.1
ROUTE_COUNT[13]=1

 
 
 
But if we want to add a range of IP, pls let me know what will be the format?
for eg: If  I've to  add static routes for  IPs ranging from :
10.14.75.0
10.14.75.1
10.14.75.2
.
.
.
.
.
.
to
10.14.75.254
4 REPLIES
crsk1234
Visitor

Re: Adding a static route for a range of IPs

Gateway will be the same for the above range of IPs

Matti_Kurkela
Honored Contributor

Re: Adding a static route for a range of IPs

This is known as a "network route". In your example, the range matches exactly a C-class network segment, also known as a  /24 in more modern terms. That segment could be specified with a combination of network address 10.14.75.0 and netmask 255.255.255.0, or as 10.14.75.0/24 in Cisco-style short form.

 

So, you would specify such a route for HP-UX as:

 

ROUTE_DESTINATION[14]="net 10.14.75.0"

ROUTE_MASK[14]="255.255.255.0"

ROUTE_GATEWAY[14]="10.253.240.1"

ROUTE_COUNT[14]="1"

 

(If you really must do something different with 10.14.75.255, just specify a different host route for it - HP-UX will automatically arrange the routing table so that the most specific entries are chosen over more generic ones, so a host route for 10.14.75.255 will be preferred over a network route for 10.14.75.*.)

MK
crsk1234
Visitor

Re: Adding a static route for a range of IPs

I added following 8 routes to the netconf file.

 

ROUTE_DESTINATION[60]="net 10.14.75.0"
ROUTE_MASK[60]="255.255.255.0"
ROUTE_GATEWAY[60]=10.15.134.4
ROUTE_COUNT[60]=1

ROUTE_DESTINATION[61]="net 10.14.76.0"
ROUTE_MASK[61]="255.255.255.0"
ROUTE_GATEWAY[61]=10.15.134.4
ROUTE_COUNT[61]=1

ROUTE_DESTINATION[62]="net 10.14.77.0"
ROUTE_MASK[62]="255.255.255.0"
ROUTE_GATEWAY[62]=10.15.134.4
ROUTE_COUNT[62]=1

ROUTE_DESTINATION[63]="net 10.14.78.0"
ROUTE_MASK[63]="255.255.255.0"
ROUTE_GATEWAY[63]=10.15.134.4
ROUTE_COUNT[63]=1

ROUTE_DESTINATION[64]="net 10.14.79.0"
ROUTE_MASK[64]="255.255.255.0"
ROUTE_GATEWAY[64]=10.15.134.4
ROUTE_COUNT[64]=1

ROUTE_DESTINATION[65]="net 10.15.40.0"
ROUTE_MASK[65]="255.255.255.0"
ROUTE_GATEWAY[65]=10.15.134.4
ROUTE_COUNT[65]=1

ROUTE_DESTINATION[66]="net 10.15.25.0"
ROUTE_MASK[66]="255.255.255.0"
ROUTE_GATEWAY[66]=10.15.134.4
ROUTE_COUNT[66]=1

ROUTE_DESTINATION[67]="net 10.16.200.0"
ROUTE_MASK[67]="255.255.255.0"
ROUTE_GATEWAY[67]=10.15.134.4
ROUTE_COUNT[67]=1

 

 

I'm getting the following error when I start the net service:

 

root:/etc/rc.config.d # /sbin/init.d/net start
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.14.75.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.14.76.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.14.77.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.14.78.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.14.79.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.15.40.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.15.25.0: gateway 10.15.134.4: Network is unreachable
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route command after the interface is up :
add net 10.16.200.0: gateway 10.15.134.4: Network is unreachable
root:/etc/rc.config.d #

 

I've attached the lanscan o/p, & few other troubleshooting steps output.

 

Matti_Kurkela
Honored Contributor

Re: Adding a static route for a range of IPs

The gateway you're trying to specify is not directly reachable by neither lan0 or lan1.

Trying to specify routes like "first go to gateway X, then from there to gateway Y" is usually futile: this is known as "source routing".

 

It turned out that source routing had very few legitimate applications and quite a lot of malicious ones, so most security recommendations for routers today insist that source routing must be disabled.

 

Without source routing, the gateway that receives the traffic from your server must use its own routing table to decide where to pass the traffic.

 

I have to say that your routing table looks very messy, and it is probably more complicated than necessary. You might want to show the output of "netstat -rnv" to your network administrator: s/he might find ways to simplify your configuration considerably.

MK