Routing Subnet – How to Route to Multiple Subnets

routingsubnet

Having a 192.168.1.0/24 network connected to a router1 on eth0, I want to access several others in the 192.168.222.0/28, 192.168.222.16/28, …, 192.168.222.240/28 range, all accessible through eth1.

Is it OK to add a single "192.168.222.0/24 via eth1" routing entry, or do I need to add one for each network "192.168.222.0/28 via eth1", "192.168.222.16/28 via eth1", …

Kind regards.

Edit

Actually, eth1 is connected to another router2, living in the first subnet 192.168.222.0/28 with the IP 192.168.222.1. That one is the one routing to all the other subnets, that is, specifying their gateways with individual rules. So that router2 is the one which would be the gateway for router1's "192.168.222.0/24 via 192.168.222.1%eth1" entry.

On router1 is it possible to insert just one rule? Can there the "route summary" Pedro Brito is talking about be applied?

Best Answer

It's generally possible. It's called a route summary and normally used to simplify routing when using static routes or to reduce the size of the routing table.

If there's a subnet in the range that isn't accessible via eth1, packets are still going to be delivered in that interface, unless there's a more specific route pointing somewhere else.