How can I join two networks

3

3

I need to join two networks like this:

PC A1   PC A2   PC A3                                   PC B1   PC B2   PC B3
  \      |       /                                        \      |       /
  ADSL MODEM/ROUTER A  -------- ethernet cable? -------- ADSL MODEM/ROUTER B
      192.168.2.x                                           192.168.1.x

What I want to do is to be able to access the network devices of network A from network B and vice versa. And I also want the devices to access the internet via the router on their respective network, for example PC A1 should access the internet via MODEM A and PC B1 via MODEM B.

So, I want things to stay as they are right now, adding the ability for PC A1 to "see" PC B1 etc. so I can transfer files between them etc.

G P

Posted 2012-08-13T22:00:43.537

Reputation: 31

1Are the routers physically close enough that you could (feasibly) run an ethernet cable between them? Or is that figuratively, like having two buildings and wanting the computers in one building to see the computers in the other building? – Darth Android – 2012-08-13T22:08:37.257

@DarthAndroid adsl modem/routers that i've used have just been a switch and a very basic built in router that many wouldn't even call a router. like a router with 2 ports. Where you can't configure it to use different IP ranges on different ports. A "proper" Router wouldn't have an ADSL modem in it , last time I used them anyway. – barlop – 2012-08-13T22:14:00.333

Depending on what you want, I've seen proper routers with cable or ADSL modems combined in. The easiest way to solve this is with a proper router, or at least one which allows you to specify custom routes. Would you happen to know the brand/model of the modem/routers in question? It would be helpful to see their actual capabilities. Do you have multiple connections ("Multi-WAN" or "Multi-homing") for redundancy purposes, or bandwidth purposes, or just because? If the router/modems are indeed super-basic, additional hardware might be involved. – Darth Android – 2012-08-13T22:19:38.540

The modem/routers are aftermarket. It's a Linksys WAG160Nv2 and a high end Netgear. I can buy/replace anything needed. – G P – 2012-08-13T22:34:01.120

Answers

2

If the networks are close enough that you can phsyically connect them with an ethernet cable, then simply do that. You'll need to add routes to each router to handle the different subnets (i.e., 192.168.2.x vs 192.168.1.x). For each router:

  1. Add a route for the other router out over the LAN interface.
  2. Add a route for the other subnet to go to the other router

For example on Router A, you should at a route for Router B's IP address (probably 192.168.2.1) over the LAN interface of Router A, and then you want to add a second route for 192.168.2.0/24 to Router B's IP address.

Repeat on router B, but with using Router A's IP and 192.168.1.0/24 as the subnet.


barlop's answer brings up some good points about DHCP and having two routers on the same physical network. While the above will get the packets to the right locations, look over his answer to make sure you have an idea how you want to deal with some of the complications that will arise from doing this.

Darth Android

Posted 2012-08-13T22:00:43.537

Reputation: 35 133

I want each router to have DHCP enabled and handle the devices connected to it. I don't quite understand your solution; Will I just connect an ethernet cable between the routers (from a port on router A to a port on router B) and set routes? How exactly need these routes to be set? I've never done anything similar even though I'm kinda experienced with networking. – G P – 2012-08-13T22:42:28.677

@GeorgePsimenos The routes tell the routers how to direct the traffic. Due to the nature of most routers, you won't be able to simply use routes and have both do DHCP at the same time (I'd use static addressing, and then configure one router with DHCP for computers that are only temporarily on the network). The routes are set in the configuration of each router, if they support it. – Darth Android – 2012-08-13T22:47:02.637

If B1 is looking for A2, then it'll try to send a packet addressed to A2 to router B. B will see that all traffic for router A's computers have to be sent to router A (Static route #2), and forward the packet to router A. The first static route specifies that router A exists on the LAN interface (where the ethernet cable is), so router B will use that to send the packet to router A. Router A simply forwards the packet to A2. – Darth Android – 2012-08-13T22:50:45.813

Much clearer now, but I'll have to try these in practice. – G P – 2012-08-13T22:56:33.900

1

You can connect Network A to a network switch, and Network B to a network switch.

Then connect each switch to a Central Router and configure the Router so one interface is for one IP range, the other for the other IP range.

And make sure DHCP isn't set on both routers. I suppose you either have to set the IPs manually to get the 2 different ranges. Or, get the central router to do the DHCP.

Those modem/routers most likely wouldn't cope with sending via DHCP one IP range on one port and another IP range on another port. My experience is they can't even cope with 2 different networks with 2 different IP ranges. But a central router (not modem-router) could and if not, then set IPs manually on each computer

That said.

You could perhaps look at it as one network 192.168.0.0 and configure both ADSL modem/routers that that's the network. Then you don't need a central router at all and can just connect them both together via ethernet cable. But then it's not two separate networks it'd be one network, but that's within the capabilities of your adsl modem-routers.

barlop

Posted 2012-08-13T22:00:43.537

Reputation: 18 677

I need the computers on each building to use that building's internet connection. – G P – 2012-08-13T22:37:52.270

1

Event if these two routers are physically connected, you'll need to setup the ports that the inter-router cable connects to differently from the others and then setup static routes.

Many home routers support neither. For the ones that do, you probably have to use the "WAN" port to connect the two routers (as the LAN ports are behind a switch chip and cannot be configured individually), which means you'll have no access to an external network unless you do a more complicated configuration.

Also, Windows file sharing host discovery (which I assume is what you mean for computers to see each other) does not work very well over different sub nets. You'll have to do some setup so the broadcast messages go through, which you probably can't on a home router. However, you can still access the files by entering the IP addresses directly.

billc.cn

Posted 2012-08-13T22:00:43.537

Reputation: 6 821

0

I would recommend adding a bridging router that would be connected to both networks. You can use pretty much any router with at least two Ethernet ports and that can run aftermarket firmware (like Tomato, OpenWRT, DD-WRT, and so on).

All you have to do in the router that connects the two networks it this:

  1. Configure each of two Ethernet ports into different VLANs.

  2. Assign each VLAN an IP address in one of your two networks.

  3. Connect each port to the network that port's VLAN has an IP address in.

  4. Make sure the router is configured to do routing. (This is the default in most distributions.)

Then, to make it work, you'll have to log into each of your two existing routers and add a route. For example, if the bridging router is 192.168.1.2 and 192.168.2.2, you'll need to add these two routes:

  1. In the 192.168.1.x network, a route to 192.168.2.0/24 with a gateway of 192.168.1.2

  2. In the 192.168.2.x network, a route to 192.168.1.0/24 with a gateway of 192.168.2.2

Note that computers in the two networks will be in different broadcast domains, so they won't easily discover each other. Depending on what tools you plan to use, there are various ways around this. For example, if you use Windows networking a lot, you can use a program (like nmbd) that synchronizes browse lists across the two networks.

David Schwartz

Posted 2012-08-13T22:00:43.537

Reputation: 58 310

Awesome answer, thanks. I have a spare TL-WR741ND with DD-WRT, would I be able to use that as a bridging router? – G P – 2012-08-14T16:44:17.387

Yes. That would work just fine. – David Schwartz – 2012-08-14T21:13:16.120