Simpler Navigation for Servers and Operating Systems
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.
Networking
cancel
Showing results for 
Search instead for 
Did you mean: 

Can ping default gateway but cant add the route (network unreachable)

SOLVED
Go to solution
EU-Admins-UNIX
Regular Advisor

Can ping default gateway but cant add the route (network unreachable)

Hi

 

I'm trying to add route as below:

 

# route add default 172.20.0.250
add net default: gateway 172.20.0.250: Network is unreachable
#

 

However I can ping it:

 

# ping 172.20.0.250
PING 172.20.0.250: 64 byte packets
64 bytes from 172.20.0.250: icmp_seq=0. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=1. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=2. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=3. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=4. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=5. time=0. ms
64 bytes from 172.20.0.250: icmp_seq=6. time=0. ms

 

Routing table is as follows:

 

# netstat -rn
Routing tables
Destination           Gateway            Flags Refs Interface  Pmtu
127.0.0.1             127.0.0.1          UH    0    lo0       32808
172.20.0.12           172.20.0.12        UH    0    lan0      32808
172.20.0.0            172.20.0.12        U     2    lan0       1500
127.0.0.0             127.0.0.1          U     0    lo0       32808

 

I'm confused.  Why can't i add the route as above and be told the netowrk is unreachable??

 

Regards

 

Tariq

 

 

1 REPLY
Patrick Wallek
Honored Contributor
Solution

Re: Can ping default gateway but cant add the route (network unreachable)

You need a '1' at the end of the command:

 

# route add default 172.20.0.250 1

 

The 1 is the number of hops to the router.

 

See the 'count' section of man page for route (man route) .