1832335 Members
2255 Online
110041 Solutions
New Discussion

route add host

 
SOLVED
Go to solution
centurion
Frequent Advisor

route add host

I have a route in my /etc/rc.config.d/netconf like this:

ROUTE_DESTINATION[22]="host 193.28.103.163"
ROUTE_MASK[22]="255.255.255.0"
ROUTE_GATEWAY[22]="10.120.3.10"
ROUTE_COUNT[22]="1"
ROUTE_ARGS[22]=""

But after a reboot the route doesn't exist?!

When I add the route manual, then it works:

route add host 193.28.103.163 10.120.3.10 1

12 REPLIES 12
Pete Randall
Outstanding Contributor

Re: route add host

I beleive that the word "host" should not be in the destination:

ROUTE_DESTINATION[22]="host 193.28.103.163"
-should read_
ROUTE_DESTINATION[22]="193.28.103.163"


Pete

Pete
HGN
Honored Contributor

Re: route add host

Hi

The should be

ROUTE_DESTINATION[22]="default"

Rgds

HGN
centurion
Frequent Advisor

Re: route add host

@Pete:

I will test your alternative ..


@ HGN:

The default route already exist. The system has three NIC's and many routes.


Thank you!
Pete Randall
Outstanding Contributor
Solution

Re: route add host

Also check /etc/rc.log to see if there are any errors noted during boot-up.


Pete

Pete
centurion
Frequent Advisor

Re: route add host

It works with "host 193.28.103.163" and without "193.28.103.163".

The problem is the netmask, when I delete the line ROUTE_MASK[22]="255.255.255.0" and reboot the system, than it works.

In the /etc/rclog I find a entry that the netmask is not OK!


Very freaky ...

Thank you very much Pete!

Regards Timo
centurion
Frequent Advisor

Re: route add host

resolved
Jim Keeble
Trusted Contributor

Re: route add host

I know you've resolved it already, but just for reference, the mask for a host route is always 255.255.255.255, ie., to match this route the destination IP has to match ALL 32 bits of the route destination. The mask you specified would require a match only of the first 24 bits.
centurion
Frequent Advisor

Re: route add host

Hi Jim,

when I add the new entry in the netconf (within the 32bit netmask) and reboot the system, the route doesn't exist.

ROUTE_DESTINATION[22]="host 193.28.103.163"
ROUTE_MASK[22]="255.255.255.255"
ROUTE_GATEWAY[22]="10.120.3.10"
ROUTE_COUNT[22]="1"
ROUTE_ARGS[22]=""


I found the following message in the /etc/rc.log:

ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with
a route commad after the interface is up :
netmask: bad value
Pete Randall
Outstanding Contributor

Re: route add host

The comments in /etc/rc.config.d/netconf explain that this field is "an optional field. A IP address, subnet mask pair uniquely identifies a subnet to be reached. If a subnet mask is not given, then the system will assign the longest subnet mask of the configured network interfaces to this route. If there is no matching subnet mask, then the system will assign the default network mask as the route's subnet mask."

Personally, I would leave it blank.


Pete

Pete
centurion
Frequent Advisor

Re: route add host

Hi Pete,

when I keep the field for the netmask clear and reboot the system, then it works.

ROUTE_MASK[11]=""

Timo
Jim Keeble
Trusted Contributor

Re: route add host

That's interesting that the route command won't allow you to specify the mask. But looking at the route with netstat -rvn confirms that the mask for a host route is 255.255.255.255. It apparently just doesn't allow it at all in the command when "host" is used.



# route add host 10.1.1.1 netmask 255.255.255.255 16.113.144.1 1
netmask: bad value
# route add host 10.1.1.1 16.113.144.1 1
add host 10.1.1.1: gateway 16.113.144.1
# netstat -rvn
Routing tables
Dest/Netmask Gateway Flags Refs Use Interface Pmtu
127.0.0.1/255.255.255.255
127.0.0.1
UH 0 3316 lo0 4136
16.113.145.147/255.255.255.255
16.113.145.147
UH 0 174982 lan0 4136
10.1.1.1/255.255.255.255
16.113.144.1
UGH 0 0 lan0 1500
16.113.144.0/255.255.254.0
16.113.145.147
U 2 0 lan0 1500
127.0.0.0/255.0.0.0 127.0.0.1
U 0 0 lo0 4136
default/0.0.0.0 16.113.144.1
UG 0 0 lan0 1500

Thanks for the info, though! Sorry I misled you.
centurion
Frequent Advisor

Re: route add host

Hi Jim, hi Pete,

This is a very nice case! :-) Thank you for your help and have a nice day!

Best regards, Timo