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

6

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?

eliman20000

Posted 2018-10-18T11:25:53.713

Reputation: 61

If you were to set up static IPs for everything you could give them different default gateways, but static everything is a pain... Or if you had a more advanced DHCP server the DHCP server could give them different default gateways. – user253751 – 2018-10-19T04:18:20.147

Answers

12

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.)

kasperd

Posted 2018-10-18T11:25:53.713

Reputation: 2 691

3I'm upvoting this because it seems to be the only response attempting to actually answer the question. – Tim_Stewart – 2018-10-18T12:55:04.063

6

Set up a USB printer server - a lot, but not every router has this built in. It would also need to be wireless so it can attach to the 4G Wi-Fi network. Something like the TL-WN822N - WLAN USB adapter.

Wi-Fi print server

Now, assuming that your printer is attached to the other network via Ethernet, the USB port should still work. The printer will now accept requests from the main network and the wireless 4G network.

JohnnyVegas

Posted 2018-10-18T11:25:53.713

Reputation: 2 820

2I'm upvoting this because even though it doesn't technically answer the question as written it provides an alternative approach to solve the requirement which motivated the question. Depending on the hardware used and specific needs this may or may not be a better solution than the plan to achieve the goal through changes in network topology. – kasperd – 2018-10-18T13:36:37.397

There isn't a tidy solution to the question without replacing the router or the printer, so if I was in the same situation users printing would come above network topology. – JohnnyVegas – 2018-10-19T06:14:11.187

1

Welcome to su.SE. Essentially, you want to route between two private networks. @kasperd's answer and @user20574's comment are actually quite close to a real solution, but there is room for improvement.

I assume your current routers are consumer devices which do not defferentiate between wireless and wire-bound connections (except for the one WAN port or the built-in modem respectively). In this case, you need a third router which is connected (via LAN preferably) to both networks. The setup could be like this:

Assume 192.168.1.0/24 to be network A.
192.168.1.1 may be the LAN IP of router A in network A.
Clients in network A are assigned an IP via DHCP by router A. The DHCP-set default gateway is 192.168.1.1.
In router A, the default gateway forwards traffic over the WAN port.
Your printer may have the IP 192.168.1.80.

Assume 192.168.2.0/24 to be network B.
192.168.2.1 may be the LAN IP of router B in network B.
Clients in network B are assigned an IP via DHCP by router B. The DHCP-set default gateway is 192.168.2.1.
In router B, the default gateway forwards traffic over the internal wireless WAN connection.

Now you connect the new router. Let's call it router C. This router is configured to forward data in between the networks it is connected to.
192.168.1.2 may be the LAN IP of router C in network A.
192.168.2.2 may be the LAN IP of router C in network B.

Now for the tricky part: Adjust the routing table in router B with an additional route: Host 192.168.1.80 (your printer) may be reached via gateway 192.168.2.2 instead of the default gateway.
This is a mock-up of how the routing-table as it should be in router B:

Destination     Router          Genmask           Iface
0.0.0.0         0.0.0.0         0.0.0.0           WAN
192.168.1.80    192.168.2.2     255.255.255.255   LAN
192.168.2.0     0.0.0.0         255.255.255.0     LAN

There will be no issue with DHCP requests being answered by the wrong server since DHCP requests are broadcasts which not routed across the network border.

However, if your router B does not allow this kind of modification, this problem cannot be solved in a properly and clean manner.

Hermann

Posted 2018-10-18T11:25:53.713

Reputation: 170

0

So you have two disjointed LANs, each with their own separate gateway to the internet. And there are server resources on one LAN that can't be seen from the other LAN.

OPTION 1 - Merge the LANs.

  • Set up the LAN address of the second router to be .2 and leave the main router as .1
  • Disable the DHCP server on one router and let the other handle DHCP serving, or set up a DHCP server on a server and disable both router's DHCP.
  • Physically wire a LAN port on each router together, via switches if required.

Now users will all be on the same flat LAN (say 10.1.2.x) and can see the internet via .1 or via .2 and everyone can see the printer at .3

For a user to elect the other link, they have to change their gateway IP address from 1 to 2. Or you as the admin can update the DHCP server to hand out the other IP as a gateway. If you go this route, set the DHCP lease time pretty small, like a minute or so.

OPTION 2 - Merge the LANs, install a firewall that is capable of dealing with multiple WAN links.

  • Similar to the first option, but instead of you making a real-world decision to change link, the firewall device monitors something via each link and can swing its own routing to the cellular, should the main (faster and cheaper?) link drop off.

Something like pfsense is fully capable of running two WANs with prioritisation and fallback. You will need a reliable host with 3 physical ethernet ports to run pfsense as your firewall.

Criggie

Posted 2018-10-18T11:25:53.713

Reputation: 985

-4

You can make it one network if you cable it as LAN-to-LAN and not LAN-to-WAN:

Image

With this setup, you only need one connection to the Internet through the cable modem. The 4G modem will become a Wi-Fi access point extending the network created by the cable modem, and should have its DHCP server disabled.

For more information, see this answer.

harrymc

Posted 2018-10-18T11:25:53.713

Reputation: 306 093

It sounds like the goal is to still use both internet connections. This answer doesn't achieve that. Moreover this answer is short on detail about how the secondary router is configured. – kasperd – 2018-10-18T12:19:05.650

The "missing" details are already in the post. The only missing piece is the cabling. – harrymc – 2018-10-18T12:33:26.920

And how do you then configure which computer use which ISP? – kasperd – 2018-10-18T12:36:40.277

Who said anything about two ISPs? – harrymc – 2018-10-18T12:45:15.143

1The question says: "we have two internet connections via two modems, one cable modem and one 4G modem" – kasperd – 2018-10-18T12:46:28.593

Who said anything about two ISPs? – harrymc – 2018-10-18T12:48:24.963

3This is an inappropriate answer. If you believe it's a duplicate, flag it as such linking it to the other question. but this in no way attempts to answer the question. – Tim_Stewart – 2018-10-18T12:58:43.743

@Tim_Stewart: I did think of doing just that, but decided that it's not really a duplicate. The subject here is unifying two existing networks, while the other just explains the differences between LAN-LAN and LAN-WAN. – harrymc – 2018-10-18T13:04:37.963

I am familiar with that answer, I actually flag and link to it pretty often in the networking section. Maybe add a relevant information to this answer? The OP would have to setup the gateways statically for the intended PC's if I'm not mistaken. Anyway, not trying to detract from your post. I'm hoping this came off as constructive and not ball busting. – Tim_Stewart – 2018-10-18T13:13:51.900

@Tim_Stewart: Glad to hear that that answer is useful. Usually the computers on the network have automatic DHCP and DNS, so will not need re-configuration. Problems may only occur if they are configured as two differently named WORKGROUPs or any other non-default network parameter. – harrymc – 2018-10-18T13:22:10.487