Operating System - HP-UX
1819901 Members
2481 Online
109607 Solutions
New Discussion юеВ

Re: Adding specific routes

 
Wim Rombauts
Honored Contributor

Adding specific routes

I'm trying for some time now to clear my routing table and enter a set of new entries.
Clearing it is not the problem, the "default" entry is OK, but the specific routes return an error.

I use the command "route add 10.128.128.0 netmask 255.255.240.0 10.128.239.254 1".
When I do that, I get the error "netmask: bad value"
I also tried network 10.128.0.0 with netmask 255.255.0.0, but that gives the same error.
I can however set network 10.0.0.0 with netmask 255.0.0.0.

So can anyone tell me what my problem is ?
9 REPLIES 9
Santosh Nair_1
Honored Contributor

Re: Adding specific routes

I think you have a syntax problem:

route add 10.128.128.0 netmask 255.255.240.0 10.128.239.254 1

should be

route add 10.128.128.0 10.128.239.254 netmask 255.255.240.0 1

i.e., the netmask comes after the destination.

-Santosh
Life is what's happening while you're busy making other plans
Edward Alfert_2
Respected Contributor

Re: Adding specific routes


what if you do:
route add 10.128.128.0 10.128.239.254 1
and let it default the netmask to 255.255.0.0?

see if that works.
"Do what you love and you will never work a day in your life." - Confucius
Ravi_8
Honored Contributor

Re: Adding specific routes

Hi, wim
i use
#route add 10.128.128.0 10.128.239.254
i never give netmask, i can logon to any servers from India to UK, but i use default gateway
#route add default x.x.x.x y.y.y.y
x.x.x.x is my gateway
y.y.y.y is the system IP.
never give up
Sridhar Bhaskarla
Honored Contributor

Re: Adding specific routes

Wim,

Some network guru can verify this. I may be wrong. I am pretty bad in binary.

I see a problem with your router

With 255.255.240.0 subnet mask on 10.128.128.0 gives you a range of 4096
subnets (12 subnet bits).

So your range is 10.128.128.1 to 10.128.143.254 and your default router 10.128.239.254 doesn't fall under this range.

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

Re: Adding specific routes

The above is only the explanation. Solution is to try with other net masks. The safer one would be 255.255.0.0.

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

Re: Adding specific routes

Hi Wim,

Syntax appears ok to me. What are the ifconfigs and sepecially the netmasks of your local attached interfaces ?
How are the netmasks on the interfaces of your gateway (10.128.239.254) ?

That the router IP is not in the range of the target network seems ok for me (this is normaly the reason to use a gateway :-) but the gateway address has to be connected to a network, that belongs to the same of the client.

There has to be a mismatch, most likely in the netmasks. If you use nonstandard netmasks, you might always have mismatches, because somebody or sometool default without asking.
Volker


Wim Rombauts
Honored Contributor

Re: Adding specific routes

Thank you for your responses already.

When I don't give a netmask myself, I automatically get a correct netmask if I look at "netstat -nrv" : the netmask is 255.255.240.0 ! Nice hint. I must add the "net" option when I do that, otherwise I get netmask 255.255.255.255

That solves the immediate problem, but I'm still curious why it shouldn't work when I give the netmask myself.

So, for Volker : I have 2 operational network cards, one with address 10.128.224.18, netmask 255.255.240.0, gateway 10.128.239.254 and one with address 172.24.8.6, netmask 255.255.252.0, gateway 172.24.11.254. This last one should become the default gateway, but some networks still have to go through the other network card.
Edward Alfert_2
Respected Contributor

Re: Adding specific routes

it should work if you do it manually if you follow the suggestion from Santosh.

see man route, the netmast comes after the destination.

even though i don't have ip addresses in the range you use, i copied and pasted your syntax and then copied and pasted Santosh's. Santosh's would have worked.. see the bellow:

yours gives me:
netmask: bad value

Santosh's gives me:
add host 10.128.128.0: gateway 10.128.239.254: Network is unreachable
"Do what you love and you will never work a day in your life." - Confucius
Volker Borowski
Honored Contributor

Re: Adding specific routes

Hi guys,

"man route" says:

SYNOPSIS
/usr/sbin/route [-f] [-n] [-p pmtu] add [net|host] destination [netmask mask] gateway [count]

So "netmask" apears to be at the right position.
I know from Solaris, that "-netmask" is an option, that is set to the end of the command.

Now I tried the exactly same command with a small variation:

# route add 10.128.128.0 netmask 255.255.240.0 10.128.239.254 1
netmask: bad value

# route add net 10.128.128.0 netmask 255.255.240.0 10.128.239.254 1
add net 10.128.128.0: gateway 10.128.239.254: Network is unreachable

The only diffrence is between "add" and "add net". I must state, that I do not fully understand the manpage on route's strategie when "net" or "host" is omitted, but it seems to make a diffrence.

I think with "route add net ..." your command will work.

Volker