Networking – How to create a subnet between two different networks

dd-wrtnetworkingroutersubnet

I need some help to build my first subnet between two routers.

My office is located near another office, and those two offices are linked together with a network cable, and both offices have independent Internet access.

Each network has their own network IP scope:

  • Network A is 10.35.1.*
  • Network B is 10.35.2.*

I would like to set a subnet between those two networks, to share network resources.

How can I set up my DD-WRT router, to route those two networks?

Here is a quick sketch of the network’s design:

Actually all Subnet mask are 255.255.255.0

     Network  A                                Network  B

    PC1              PC2                 PC3              PC4         
(10.35.1.10)    (10.35.1.11)         (10.35.2.12)    (10.35.2.13)
     |                |                   |                |
     ------------------                   ------------------
             |                                    |
      Router A (DD-WRT)  --------------------  Router B
        (10.35.1.1)                          (10.35.2.1) 
             |                                    |
             |                                    |
         {Internet}                           {Internet}

Edit:
Now I've added a manual static route in the router at 10.35.1.1 (highlighted in yellow in the image)
But still can't ping 10.35.1.1 from Router TelNet or PC from the Network A
Full routing table

Best Answer

First off, each local network would be its own subnet (which is shorthand for "subnetwork", where "network" refers to the entire network; in your case, the "network" is most likely the Internet). What you need to do is set up routing between the two subnets. They will remain separate entities, but traffic will be able to flow between them.

The first thing you need to confirm is that the IP ranges are non-overlapping. For example, 10.35.1/24 and 10.35.2/24 is fine, but 10.35.1.0/16 and 10.35.2.0/16 is not (because in the latter case, the IP ranges overlap and there is no good way for the router to know which traffic should go where).

I don't know exactly what steps you need to take to configure this in dd-wrt (as in "click here, type this, ..."), but what you need to do is:

  1. Physically connect Router A to Router B (either wired or wireless, direct or through a tunnel, but they need a way to talk to each other).
  2. Configure Router A to route any traffic intended for the network served by Router B (10.35.2/24) across its link to Router B.
  3. Configure Router B to route any traffic intended for the network served by Router A (10.35.1/24) across its link to Router A.
  4. On both routers, set up any necessary firewall rules to allow the traffic to flow between the networks served by Router A and Router B. Depending on the specifics this may or may not be strictly required.

Steps 2 and 3 (which are the magic sauce for making this work at all) are usually accomplished through setting up static routes. Any moderately competent IP stack provides a way of doing this, and I can't imagine that dd-wrt would be any exception, though the exact mechanics of how to do that vary. The general idea is to tell each router that "to reach the network a.b.c.d/e", it needs to "forward the traffic over link fghij" and/or "pass the traffic to next hop router k.l.m.n"; this is how all routing on an IP network such as the Internet works. If you are specifying a next hop router, then that router must be reachable through some other configured route.

For example, consider the following IPv4 routing table, which should be similar to what you have set up:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

What this says is: to reach network 192.168.1.0 netmask 255.255.255.0 (which corresponds to 192.168.1/24), use gateway 0.0.0.0 (that is, just dump the traffic onto the network) over the interface eth0. To reach the network 0.0.0.0 netmask 0.0.0.0 (or 0.0.0.0/0, the "default route"), the best option is to ask 192.168.1.254 to forward the traffic toward its ultimate destination. Only core network routers have no default route; that's called the DFZ or Default-free zone. When you get a "no route to host" error, it's almost always because you have hit a router that has no way of passing the traffic on toward the destination host.

Routes are always considered in a most-specific-match-wins fashion, and also as a consequence the default route is only consulted if no other configured route matches. Hence, if I want to route traffic to 172.16.128.0/23 over the physical link attached to eth1, I would end up with a routing table much like the following:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
172.16.128.0    0.0.0.0         255.255.254.0   U     0      0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

By making the corresponding change on the other side, I can ensure that the return traffic will be able to flow back to the originating network, enabling two-way communication over the dedicated link.

Once you have made this type of change in your dd-wrt configuration on both ends, hosts on the two networks should at least be able to talk to the router on the other end of the link. (At that point, it very likely comes down to configuring the firewall to allow appropriate traffic through.)

Related Question