1834140 Members
2961 Online
110064 Solutions
New Discussion

one route add question

 
thebeatlesguru
Regular Advisor

one route add question

i wanna a add a route to net 192.168.26.0/24 through 192.168.26.1 ,and now i can reach 192.168.26.1:

#ping 192.168.26.1
PING 192.168.26.1: 64 byte packets
64 bytes from 192.168.26.1: icmp_seq=0. time=1. ms
64 bytes from 192.168.26.1: icmp_seq=1. time=0. ms
64 bytes from 192.168.26.1: icmp_seq=2. time=0. ms

----192.168.26.1 PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/0/1

so i use route add cmd to do it ,but something wrong , and i cant understand what the mesg means:

#route add net 192.168.26.0 netmask 255.255.255.0 192.168.26.1
add net 192.168.26.0: gateway 192.168.26.1: Network is unreachable

any idea ?
hihi
6 REPLIES 6
Jeff Schussele
Honored Contributor

Re: one route add question

Hi,

You don't need the fourth octet in that command - the net statement implies it.

Assuming that 192.168.26.1 is the IP for a NIC in the system - try

route add net 192.168.26 netmask 255.255.255.0 192.168.26.1 0

Note the last value (0) that's hop count. Must be 0 to route thru a local NIC.
If that's a router change to 1.

route add net 192.168.26 netmask 255.255.255.0 192.168.26.1 1

HTH,
Jeff


PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Michael Steele_2
Honored Contributor

Re: one route add question

Everything OK with default route?

netstat -rn

/etc/rc.config.d/netconf has no problem with your default route?

Is ip_ire_gw_probe = 0?

ndd -get /dev/ip ip_ire_gw_probe


Should work with "...route add net..."
Support Fatherhood - Stop Family Law
Sridhar Bhaskarla
Honored Contributor

Re: one route add question

Hi,

192.168.26.0/24 is in the same broadcasting domain as of the router you mentioned.

If you are able to reach the gateway directly without going through your default router, you do not need to add any routes because you are also in the same broadcasting domain. Try to ping some of the systems in that subnet and see if you get any response.

If your 'netstat -in' does not give any local interface in the 192.168.26 network, then you are pinging to the above router through the default gateway and again in that case, you do not need to add routes.

Please post your 'netstat -in' output.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
T G Manikandan
Honored Contributor

Re: one route add question

As Sri suggested
if your machine is of same network like 192.168.26.x then there is no need to add a default router for that network.

Else

#route add 192.168.26.0 192.168.26.1 1

1 is the metric which specifies whether the gateway is a remote machine or a local one.
1--->remote
0--->local

Make the appropriate entries in the /etc/rc.config.d/netconf file to persist the entries even after reboot.
Like

ROUTE_DESTINATION[0]=192.168.26.0
ROUTE_MASK[0]="255.255..255.0"
ROUTE_GATEWAY[0]=192.168.26.1
ROUTE_COUNT[0]=1



THanks
KapilRaj
Honored Contributor

Re: one route add question

192.168.26.0 & 192.168.26.1 ar in the same subnet with 255.255.255.0 netmask

Why do you need a router to reach your local subnet?.

Regds,

kaps
Nothing is impossible
Adam J Markiewicz
Trusted Contributor

Re: one route add question

Hi,

I agree with Jeff and T G.

Your
#route add net 192.168.26.0 netmask 255.255.255.0 192.168.26.1
is interpreting the last, missing argument as 0 (by default).

The result of this command is somewhat like:

'routing to the 192.168.26.0 network shoud be made through my LOCAL INTERFACE of address 192.168.26.1', wich is simply not existing.

Changing it to
#route add net netmask 255.255.255.0 192.168.26.1 1

Changes the interpretation to somewhat like:

'routing to the 192.168.26.0 network shoud be made through my EXTERNAL GATEWAY of address 192.168.26.1', wich is what you intend to do.

However indeed it is strange that you do have access to the 192.168.26.1 (which is in the 192.168.26.0) and you dont have routing to the network. Although it would be possible to define single host in the routing tables, so that could happen.

Good luck
Adam
I do everything perfectly, except from my mistakes