1832871 Members
3451 Online
110048 Solutions
New Discussion

route add

 
DIEGO_5
Occasional Advisor

route add

Hi
how can I add a host to my routing table? route add host...and then? The error say network unreachable

Thanks
18 REPLIES 18
Alex Lavrov.
Honored Contributor

Re: route add

Hey,

in route add, you add destination network/host and tell the server how to reach it, by specifing gateway.

If you get an error "network unreachable" it means that you cannot reach that network through the gateway you specified. Check that you have a ping to that gateway.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Keith Bryson
Honored Contributor

Re: route add

Hi Diego

Don't forget the metric on the end. I just did this and it worked:

route add stan 10.24.240.1 1

stan is the name of the remote server
10.24.240.1 is the gateway
1 is the metric

Keith
Arse-cover at all costs
DIEGO_5
Occasional Advisor

Re: route add

ok. but which gateway my local gateway or remote?

thanks
Keith Bryson
Honored Contributor

Re: route add

Whichever host/router that knows how to get to the remote IP. The remote server must also know how to get back, so consider that too.

Keith
Arse-cover at all costs
Alex Lavrov.
Honored Contributor

Re: route add

If your local gateway knows how to reach that network, you can use it.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
DIEGO_5
Occasional Advisor

Re: route add

I can't ping the remote host, have I put the destinatio gateway to the route add? example route add host "remote_ip" "remote_gateway_ip"?? it is correct?

thanks
ciao
Keith Bryson
Honored Contributor

Re: route add

To clarify (a simplified setup, although other gateways could exist in-between):

Host A
|
Gateway A
|
|
Gateway B
|
Host B

Host A is on the same network as Gateway A
Host B is on the same network as Gateway B
Gateway A knows which networks are accessible via gateway B
Gateway B knows which networks are accessible via gateway A

There you go - clear as mud! Keith
Arse-cover at all costs
Keith Bryson
Honored Contributor

Re: route add

No.

You need a local gateway. Your host won't know how to get to the remote gateway either.

Keith
Arse-cover at all costs
Keith Bryson
Honored Contributor

Re: route add

So, in my scenario:

Myhost (10.24.246.1)
|
Gateway A (10.24.240.1)
|
|
Gateway B (193.128.202.200)
|
stan (193.128.202.111)

The importance here is that both gateways are aware of the networks they both have access to (either immediately connected, or through other gateways). If you set the route and still can't ping, check the routers.

Keith
Arse-cover at all costs
DIEGO_5
Occasional Advisor

Re: route add

ok now I have in the destination the remote ip output of (netstat -r) but I can't ping it, what mean?
Alex Lavrov.
Honored Contributor

Re: route add

That means, that the gateway you supplied cannot reach that network.

I think you should consult you network team, so they can tell you if i's possible to reach that network from yours.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Stephen Keane
Honored Contributor

Re: route add

You can also try traceroute, as in

traceroute remotehost_ip

This will show you how far you are getting.
You can always Ctrl-C it if it hangs.

DIEGO_5
Occasional Advisor

Re: route add

with the traceroute i don't reach the remote_ip
Keith Bryson
Honored Contributor

Re: route add

Diego

As long as you have added the local gateway to the route add command, make sure with your network team that the gateway (assumed to be a network router) can reach the remote site.

Keith
Arse-cover at all costs
Alex Lavrov.
Honored Contributor

Re: route add

It means that you cannot reach remote network from your network ...
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Stephen Keane
Honored Contributor

Re: route add

> with the traceroute i don't reach the remote_ip

What is the actual output of the traceroute command though?

Does it get somewhere before it gives up?
DIEGO_5
Occasional Advisor

Re: route add

the output stopped after few hop, but the remote is not show i have execute this command:

route add host "remote_ip" "my_default_gw" 1

thanks
Ron Kinner
Honored Contributor

Re: route add

If traceroute makes it a few hops then your route statement worked. Assuming there are no filters or firewalls in place then the problem is that your target (or one of the routers on the way) does not know how to get back to your network.

Get someone at the target to run a traceroute back to you and see what happens. They probably need to add a route at that end.

You will need to modify /etc/rc.config.d/netconf in order to keep the route. Otherwise it will vanish at the next reboot.


ROUTE_DESTINATION[n]="network_address"
ROUTE_GATEWAY[n]="gateway_address"
ROUTE_COUNT[n]="1"

n is just the next available integer and has nothing to do with the interface number.

If the route works for about three minutes then stops working your gateway is not responding to pings and you will need to either have the gateway admin allow it to respond to your pings or turn off dead gateway detection with ndd.


Ron