Linking Subnets with Static Routes

From DD-WRT Wiki

Revision as of 12:47, 7 September 2009 by Phuzi0n (Talk | contribs)
Jump to: navigation, search

Contents

Introduction

This guide aims to explain how to link different subnets together using static routes to forward traffic to the desired subnet of another router. I will avoid going into too much detail about subnetting in general, though I will say that there are benefits to using subnets such as reducing network traffic (less broadcast frames) and better access control between hosts. One important thing to note for those unfamiliar is that linking subnets is called routing, and the interfaces you use should be unbridged to do it correctly.

Creating the Subnets

There are many ways to create subnets within DD-WRT. By default only the WAN port is unbridged while the switch (which is a hardware bridge) and wireless interfaces are software bridged together.

Ways to create additional subnets include:

  • Set the wireless interface to 'Unbridged'
  • Configure VLAN's if your switch supports them
  • Add virtual interfaces to any existing interface which is poor design but can overcome hardware limitations such as switches without vlans.
ifconfig eth0:1 [NEW SUBNET ROUTER IP] netmask [NETMASK] broadcast [BROADCAST]

Baseline Reference Example

Now let's say you have three routers connected together. Router1's WAN port is connected to the internet which makes it the gateway of your entire LAN, and Router2 and Router3 have their WAN ports connected to Router1's LAN ports. Router2 and/or Router3 could also be using Client or Repeater mode (not bridged!).


Image:Static_Routes_1.png


By default all of these routers will be operating in 'Gateway' routing mode which means they do Network Address Translation (NAT) which makes their LAN subnet addresses invisible on their WAN side. Because each router has an interface connected to the 192.168.1.0/24 subnet, they all have routes to this subnet. However, Router1 doesn't have a route to 192.168.2.0/24 or 192.168.3.0/24, Router2 doesn't have a route to 192.168.3.0/24, and Router3 doesn't have a route to 192.168.2.0/24.

Configuring the Static Routes

For this particular topology only Router1 will need to be configured with static routes because the others have default routes that will cause them to forward traffic to Router1 for any subnet they don't explicitly have routes to.


The next step needed is to disable NAT on Router2 and Router3 by switching their Operating Mode from 'Gateway' to 'Router' on the Setup->Advanced Routing page.