Saturday, July 24, 2010

How to: 2 (or more) Router Networking

There are a lot of great places online to read about subnets and routing. It's worth a quick read, and the information is consistently repeated everywhere. There isn't however a whole lot on how to set up a network with two routers or on using subnets.

Here is what I figured out after a long night of toying with things:
  • If you want to use two routers in a network, just connect the WAN port of the second router into a LAN port on the first one.
Simple right? I can't believe it took me so long to figure this simple concept out. But before you go just plugging routers into one another, you have to take some initial steps to ensure they play nicely. Here they are:
  • Make sure your routers are using different subnets/assigning different (unique) IP ranges.
    (Mine use 192.168.1.1 and 192.168.0.1 with subnet mask 255.255.255.0)
  • Make sure you understand subnet masking to some small extent.
  • Draw up how you want your network to behave/look before you get started. This is often a good idea for larger more complex networks.
  • Make sure there is no contention between wireless and other network settings. (i.e. turn off or reconfigure wireless to be different across the hardware.)
  • Assign all secondary hardware with static IP's in the range of the primary. (Obviously don't use an IP already in use like 192.168.1.1)
Once you've set up two routers to map hosts on two different subnets, it's time to link them together. Plug the WAN port of your secondary router (Mine was subnet 0) into a LAN port of your primary (subnet 1). The network on your secondary router should now be able to reach the internet and also network hosts on your primary router.

However, if you want the hosts on subnet 1 to see subnet 0 then you need to set up a small and simple routing rule on the primary router. The routing rule looks something like this:

DestinationSubnet MaskGateway
192.168.0.1255.255.255.0192.168.1.2

Where 192.168.1.2 is the external (static) IP of subnet 0, the secondary router. The internal IP of subnet 0 is still 192.168.0.1. And with this new routing rule you can now access it from the primary network.

Happy Routing!