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

8,340

Solution 1

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

Solution 2

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.

Solution 3

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.

Share:
8,340
eliman20000
Author by

eliman20000

Updated on September 18, 2022

Comments

  • eliman20000
    eliman20000 over 1 year

    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?

    • user253751
      user253751 over 5 years
      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.
  • kasperd
    kasperd over 5 years
    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.
  • harrymc
    harrymc over 5 years
    The "missing" details are already in the post. The only missing piece is the cabling.
  • kasperd
    kasperd over 5 years
    And how do you then configure which computer use which ISP?
  • harrymc
    harrymc over 5 years
    Who said anything about two ISPs?
  • kasperd
    kasperd over 5 years
    The question says: "we have two internet connections via two modems, one cable modem and one 4G modem"
  • harrymc
    harrymc over 5 years
    Who said anything about two ISPs?
  • Tim_Stewart
    Tim_Stewart over 5 years
    I'm upvoting this because it seems to be the only response attempting to actually answer the question.
  • Tim_Stewart
    Tim_Stewart over 5 years
    This 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.
  • harrymc
    harrymc over 5 years
    @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.
  • Tim_Stewart
    Tim_Stewart over 5 years
    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.
  • harrymc
    harrymc over 5 years
    @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.
  • kasperd
    kasperd over 5 years
    I'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.
  • JohnnyVegas
    JohnnyVegas over 5 years
    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.