route add
I want to add route to reach the computer 192.168.1.141 through the gateway 192.168.1.41.
I tried the following but the error is "SIOCADDRT: Network is unreachable". # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.31.1.0 * 255.255.255.0 U 0 0 0 eth0 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0 default 172.31.1.1 0.0.0.0 UG 0 0 0 eth0 # ping 192.168.1.41 PING 192.168.1.41 (192.168.1.41) 56(84) bytes of data. 64 bytes from 192.168.1.41: icmp_seq=0 ttl=64 time=61.7 ms 64 bytes from 192.168.1.41: icmp_seq=1 ttl=64 time=1.53 ms 64 bytes from 192.168.1.41: icmp_seq=2 ttl=64 time=56.1 ms --- 192.168.1.41 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 1.538/39.821/61.780/27.168 ms, pipe 2 # route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.41 SIOCADDRT: Network is unreachable |
Routing table is local. You can only set up routing via gateway if the gateway is in your local network (network addresses of any of your nics). The route you're trying to add doesn't look local, so it should be handled somewhere later, for example by your default gateway.
|
Do you mean my routing table do not need to be modified and
the route for 192.168.1.x should be added at the default gateway (172.31.1.1)? Quote:
|
All traffic that doesn't have another route defined for it will be sent to the default gateway (this is the point of having a default gateway). As long as the gateway knows how to route the traffic or pass it on to another gateway that does, you are fine.
|
To clarify, yes. You don't need to modify your routing table.
|
All times are GMT -5. The time now is 09:05 PM. |