You have several private subnets to traverse, and they are not all connected to the same physical router, so how do you give them access to each other?
There is an easy way and a hard way. The hard way is to create static routes from router to router. Suppose you have three subnets and three routers, like Figure 6-3 shows.
Each router will need two routes. For example, you would set the routes on Router C like this:
# route add -net 192.168.10.0/24 gw 172.24.0.25 eth1
# route add -net 172.16.5.0/24 gw 172.24.0.25 eth1
Then, Router B:
# route add -net 192.168.10.0/24 gw 172.16.5.125 eth1
# route add -net 172.24.0.0/24 gw 172.16.5.125 eth1
And, Router A:
# route add -net 172.16.5.0/24 gw 192.168.10.100 eth1
# route add -net 172.24.0.0/24 gw 192.168.10.100 eth1
Now, hosts on all three subnets can communicate with each other. Deleting routes is done like this:
# route del -net 192.168.10.0/24
This is a fair bit of work; you have to know netmasks, and be very careful not to make typos. The easy way is to put all three routers on the same network, like in Figure 6-4.
Now, you don't need to set routes at all.
You may also use ip to set and remove routes:
# ip route add 172.16.5.0/24 via 192.168.10.100
# ip route del 172.16.5.0/24
It doesn't take long for the charm of setting static routes to wear off. The other easy way is to use dynamic routing, which we'll get to starting with Recipe 6.7.