# route command



## andronicus (Nov 13, 2022)

I am using the route command. I have added a new route but I cannot ping the new destination address. Here is the relevant portion of my routing table:

Destination           Gateway              Flags     Netif     Expire
192.168.1.0/24     10.1.0.2               UGS      lan0

I have a router, 'routerA', connected to the Internet on one interface and also configured for another network on a second interface, I also have a second router, 'routerB', configured to access routerA and also configured to access another network. 

routerA is configured to access network1, '10.1.0.0/24'. routerB is configured to access 10.1.0.0/24. routerB is also configured to access network2, '192.168.1.0/24'.

I want routerA to access the 192.168.1.0/24 network residing on routerB.

I have used this command to add the above line to routerA's routing table:

route add -net 192.168.1.0/24 10.1.0.2

I want to ping a host configured with the address 192.168.1.166 on the 192.168.1.0/24 network:

routerA@10.1.0.1: ping 192.168.1.166

No response:

7 packets transmitted, 0 packets received, 100.0% packet loss.

Any help would be good.


----------



## Jose (Nov 13, 2022)

andronicus said:


> I want to ping a host configured with the address 192.168.1.166 on the 192.168.1.0/24 network:


Does this host have a route back to routerA? What is the default gateway on network 192.168.1.0/24?


----------



## andronicus (Nov 13, 2022)

No. 192.168.1.166 does not have a route to routerA. The gateway for the default route on 192.168.1.166 is routerB. The gateway for the default route on routerB is routerA.


----------



## andronicus (Nov 19, 2022)

any ideas?


----------



## covacat (Nov 20, 2022)

use tcpdump on the routers


----------



## VladiBG (Nov 20, 2022)

On the other router you need to have the opposite route so he can know how to reach the other network.

For example
The network behind R1 with IP 192.168.1.1 and IP 10.1.0.1 is 192.168.1.0/24
The network behind R2 with IP 192.168.2.1 and IP 10.1.0.2 is 192.168.2.0/24
The network between R1 and R2 is 10.1.0.0/30

So on the router1 who has 10.1.0.1 add
route add -net 192.168.2.0/24 10.1.0.2

On router 2 who has 10.1.0.2 add
route add -net 192.168.1.0/24 10.1.0.1

The clients behind R1 and R2 have they default gateway they router
Hosts on 192.168.1.0/24 have default gw 192.168.1.1 (R1 LAN IP address)
Hosts on 192.168.2.0/24 have default gw 192.168.2.1 (R2 LAN IP address)
R1 know that 192.168.2.0 is behind R2
R2 know that 192.168.1.0 is behind R1


----------

