Trying to create two subnets with communication between them

Okay, i'll try to explain what i'm trying to do in detail... I really don't know much about this, so i apologize for any inaccuracy.

I have four routers from my ISP (VERY limited in what they can do), and two of them are connected to the internet independently.

I want to create two networks, each one being able to access the internet through each of the mentioned routers. But i want to be able to connect both networks so that all the devices in them can see each other.

I tried using the routers' configs, but wasn't able to (either they're too limited, i'm missing something or both). And now, i had the idea to install OpenWRT in a Raspberry Pi, to try to manage both networks. Having two separate DHCP servers in such a restricted environment made my network a right mess, honestly.

But yeah. With OpenWRT, I've tried using VLANs, creating two virtual interfaces (although the RPi has only one ethernet port), and i don't even know what else.
And i managed to set up a DHCP server in each interface with ranges 192.168.1.X and 192.168.11.X, but only the first one gets assigned to every device (unless i manually set a device lease with the second one).

The internet connected routers are 192.168.1.1 and 192.168.11.1, and i want to make it so that whatever router i connect to, the DHCP server will assign an IP from that specific range. For instance, If i connect to 11.1, it will assign 11.X.
I ASSUME that doing this will make the device i connect use the internet connection that is provided by the router that is in the same subnet.

But yeah... I really dont know.
To sum up: I want to make two networks, each with an independent internet access, but in a way that all devices in both networks are connected and can see each other.

Are the two ISP routers physically far apart, are you able to connect them to a single OpenWrt device? And how are you expecting to manage both networks since your RPi only has a single interface, and you didn't add more. Are the devices on your LAN only expected to connect over Wi-Fi?

Assuming, a. you have an OWrt router with at least four Ethernet ports, b. you can connect both upstream routers to the OWrt device, the solution is straightforward. By defailt, OWrt has a single wan interface, you can use them for ISP1, create another interface wan1, with it's own firewall zone, wan1 as well. Do the same for LAN, create another set of interface and firewall zone. Then you'll need to create two more virtual bridges to assign to both the interfaces. With all that done, you can now set up routing. In firewall, you'll already have a lan to wan masquerade, and you need to do the same for the new firewall zones you created wan1 and lan1. And for devices in both LANs to be able to talk to each other, you can allow forward lan to lan1, and lan1 to lan.

The routers can be connected between them and then from any of them to the RPi. I can literally use one wire to connect both networks.

That's how i thought i would be able to set it up. I was hoping there would be something in the software that allowed me to divide the network virtually (connecting it all and then dividing it using the routers' IP or something of the sort), and not physically (Connecting both networks to the router with two different wires).

If there's any way i could do this using the pi and it's only ethernet port, i'd appreciate it.
Otherwise, do you have a reccommendation for an affordable router in which OWrt can be installed to do this?


Edit:
By the way, completely unrelated, but i just noticed that the timestamps on these messages are backwards. My first message says "5m ago", and my last (this one) says "1h ago". Just thought i'd say it, just in case... lol

Sorry, how does that work, can you share a quick diagram? Are the ISP routers connected to each other?

Technically, you can have a switch, to which all three routers and other devices are connected to. Disable DHCP on both ISP routers, manually configure OWrt to have IP addresses and gateway to be able to talk to both of them. And configure VLANs on each of your client devices so they connect to the correct network... It's going to be overly complicated for no reason.

That would depend on your region, so I can't help. You can look OpenWrt's Table of Hardware and see which is suits your needs and available at a reasonable price at your location.

Odd, appears correctly to me.

Maybe this is applicable to your solution?

https://www.youtube.com/watch?v=fOYmHPmvSVg

I hope this is enough. It's basically the way i got it set up right now.

Yeah, this diagram explains a lot... and raises more questions. Are you able to access .11.1 when you're connected to the middle router?

That may work, yeah.

I'd have to learn to use it if i want to apply it to my case, but the video looks really useful. Thank you!

Yes. The RPi, for instance, can ping 11.1. And by the way, the RPi's IP is 192.168.1.29 for now. Forgot to put that in the diagram.

Edit: Just in case, my phone conected to 1.2 can also access 11.1 using the web browser.

... okay then. But I still stand by my word, a single cable to everything is unnecessarily complex. Even in that video, the configuration is only slightly simpler, and if you have to buy a managed switch, you can just get a complete router instead.

Or if you have any spare, old computers lying around, you can use that... Oh, wait, that's going to need another Ethernet port, with another purchase of a network card, so never mind.

Either, get a normal router or add at least two USB to Ethernet adapters. By the way, how many devices do you expect to connect to either of your LANs? Are they directly connected to ISP router or do you have a switch that's connected to router?

A normal router was the option if i couldnt make it work this way, yeah. A cheap one that's able to have OWrt installed would be more than enough for this, i think.

And about devices, the main network is 1.1, because that's the one that all my family uses and the one that will never have a need to be switched off. That one will get the majority of the devices.

The other internet connection is just for me not to bother my family if i have to turn it off or on while doing my shenanigans. So it won't have as many devices, at all.

I'm thinking that I could just assign static IPs in the DHCP settings of OWrt to the few devices that i want.
But i was hoping to find a way to make it automatic so that as soon as a device connects to that specific router it gets assigned an IP from that specific subnet (11.X).
And making it a bit more complicated like this is a great opportunity for me to learn, as well.

Can you install static routes in the ISP routers?
Each main router needs to be made aware of the other LAN, and that the Pi is the gateway between the two.
Router 1: 192.168.11.0/24 via 192.168.1.2
Router 2: 192.168.1.0/24 via 192.168.11.2
The device in the very center of your drawing would be the OpenWrt router. It needs to have two separate physical ports. Each port holds an IP (192.168.X.2) on its respective network. You can use a Pi's Ethernet and wireless for this, but the wireless in a Pi is not highly performant at all. Much better to have two Ethernet ports.

Precisely the problem is that OWrt is in a RPi (One ethernet port).

I could buy a USB to Ethernet adapter, maybe. But i'm not sure how that would go.

And if i could use the 1.2 router as an "adapter" for the Pi, it would solve both of the problems you mentioned. It would allow me to make the RPi, essentially, the center of the diagram, and it would make it so that i don't have to use WiFi at all.
Precisely that is the reason i'm trying to do it that way.

And yes, i have access to every router, but being my ISP's, it's quite limited. I can use static routing, though.

Maybe there's some routing i can add to the 1.2 router so that everything is sent through it to the RPi?
Basically, i'm attempting to turn this router into the switch we were speaking about before with the youtube video that was sent.

If i were able to do something like that, maybe the RPi could use the router's ports as if they were its own. Though that is probably complicated as hell. xD

This is going to require an actual router in the middle, not a switch (though some high-end switches with "layer 3" capability can do this-- it's not an OpenWrt question at that point).

Adding USB Ethernet to a Pi is quite simple though since you want > 100 Mb you will need a Pi 4 and a USB3 / GbE adapter.

No, that's actually pretty easy. Disable DHCP on ISP, configure gateway to ISP router on RPi, and enable DHCP on the same interface. Since you're connecting to the switch on ISP router, any device connected to it will receive DHCP from RPi/OWrt. Now, have another interface similarly connected to second ISP router, and you're halfway there.

In a video sent earlier it showed it with a "Managed Switch", i think.

It's basically an "extension" for the RPi. It would make the RPi able to use the switch's ports as its own.

If i could do that with this router i already have installed right here, though... :thinking: :grin:

Yes you can use a managed switch which sends multiple VLANs over the cable to the Pi single port. It is called trunking. This is logically the same as having multiple ports on the Pi itself, though more complicated to set up.

Speaking of which, if you do intend to go managed switch method, consider switches that you can actually install OWrt on.

Oh, I'll try it.

To see if i got that properly:
Disable DHCP basically everywhere except the RPi (Already did that earlier) - All my devices, no matter which router they are connected to, are already receiving DHCP from RPi.

Next... Configure the interface's gateway to... 192.168.1.1?
imagen
This way?

And then, another interface. A physical interface? Like... An ethernet port connected to 192.168.11.1?

My idea is to have 192.168.1.2 connected with both 1.1 and 11.1, and then use it with the RPi as if 1.2 was a managed switch (basically to give the RPi the necessary connectivity).

Yes

Only if 1.2 can do VLAN. Otherwise, no luck.