Networking – Two Internet connections via two modems, one router, specify which modem to use on PC

internetmodemnetworkingrouterwireless-networking

At work, we have two Internet connections via two modems, one cable modem and one 4G modem. To the cable modem, there is a Wi-Fi router connected, and that is our network A. The 4G modem has a built-in Wi-Fi router, and that is our network B. Some of the computers use network A, and some use network B.

Now the problem: On network A there is a network printer that we would like to access also from the PCs on network B. My plan now is to connect router A and router B with a cable, disable DHCP on router B and give it a static IP address.

How is it possible to specify for each computer which Internet connection to use?

Best Answer

You can run a single network with two DHCP servers by assigning the same network prefix but different ranges of IP addresses. For example:

Router 1:

Network address: 172.25.60.0
LAN interface: 172.25.60.1
Netmask: 255.255.252.0
Broadcast: 172.25.63.255
DHCP range: 172.25.61.0 - 172.25.61.255

Router 2:

Network address: 172.25.60.0
LAN interface: 172.25.60.2
Netmask: 255.255.252.0
Broadcast: 172.25.63.255
DHCP range: 172.25.62.0 - 172.25.62.255

The tricky part then is to ensure that each device get a DHCP response from the intended router such that they will use the intended gateway. By default they will simply use whichever is fastest to respond. And since you appear to have a different access point connected to each router, that might just work as expected - most of the time.

That's not quite satisfying. If the routers allow you to specify a whitelist/blacklist of MAC addresses to which they assign addresses you can use that to control which device gets to use which gateway. That will have the device use the same gateway regardless of which of the access points it connects to.

Alternatively you can disable DHCP on both routers and use a separate device to act as DHCP server. On that separate device you can install a much more flexible DHCP server. Any Linux machine with ISC dhcpd would work.

A completely different approach is to configure one of the routers as IPv4-only and the other as IPv6-only. That will allow all devices to use both routers depending on what's supported by the services they are communicating with. (This requires at least one of the ISPs to support IPv4 and at least one to support IPv6.)

Related Question