Community discussions

MikroTik App
 
enricosm60
just joined
Topic Author
Posts: 23
Joined: Tue Nov 14, 2023 11:22 pm
Location: Panama

connect a switch to two routers

Thu Jun 13, 2024 7:01 pm

Hello,
I have little knowledge and would like to receive help to setup an RB260GS to connect to two routers I have (one for home and another for lab) each with is own internet. To explain better how I think this will be done I'm including a diagram. The idea is that any device (PC or laptop) connected to the switch ports Eth3 to Eth5 can communicate whit both routers, the first one connected to switch Eth1 and the other to Eth2; lastly the default internet connection for the devices on Eth3, 4 and 5, would be the router on Eth1.

Thanks in advance for any help.
Enrico

Image
You do not have the required permissions to view the files attached to this post.
 
jollyrogr
newbie
Posts: 26
Joined: Sun Apr 21, 2024 10:31 pm

Re: connect a switch to two routers

Fri Jun 14, 2024 7:02 pm

I'm no expert either but it would seem to me you need a router instead of a switch there, or reconfigure the network architecture.
 
jaclaz
Forum Guru
Forum Guru
Posts: 2101
Joined: Tue Oct 03, 2023 4:21 pm

Re: connect a switch to two routers

Fri Jun 14, 2024 7:20 pm

If there are different subnets you actually need "routing" between them.
In your case the clients on 192.168.100.0/24 will need a route (and a gateway) to be able to reach either 192.168.88.1 or 192.168.0.1, or you will need a much larger netmask, a /16 would do, as it would give:
HostMin: 192.168.0.1
HostMax: 192.168.255.254
but AFAIK it is not common/advised to use such a large netmask if there is only a bunch of devices.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22155
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: connect a switch to two routers

Fri Jun 14, 2024 11:28 pm

The function of a managed switch is generally to accept a trunk port coming with a bunch of vlans including a management or trusted vlan upon which the switch gets its own IP address.
The switch then funnels all the vlans out its ports to either dumb devices ( access ports ), smart devices ( trunk port) or hybrid device ( hybrid port).
The switch is not there to create new SUBNETS.

Hence why folks are looking at your statements and thinking you need a router not a switch at that location.
 
enricosm60
just joined
Topic Author
Posts: 23
Joined: Tue Nov 14, 2023 11:22 pm
Location: Panama

Re: connect a switch to two routers

Sun Jun 16, 2024 3:49 am

Hello Anav,
So if I got this right the above diagram is not viable, then the solution would be to simply have two NICs for each computer and connect each NIC to a router?
 
jaclaz
Forum Guru
Forum Guru
Posts: 2101
Joined: Tue Oct 03, 2023 4:21 pm

Re: connect a switch to two routers

Sun Jun 16, 2024 11:58 am

The diagram is viable, the address ranges you proposed not so much, IMHO.

What is not clear (to me at least) is how would one of the PC's (let's take as an example the laptop connected to ether3 of the switch) be configured (for the moment let's set aside VLANs)?
IP address: any in 192.168.100.2-253 range, either static or DHCP
Subnet mask: 255.255.255.0 (/24)
Gateway: ? I presume EITHER 192.168.0.1 OR 192.168.88.1 (BOTH not reachable from192.168.100.0/24 :shock: ) BTW you can normally have more than one IP address and gateway on the same connection/NIC

Who/which device will decide which of the two routers will be used (as gateway/for internet access)?
Are you looking for a failover setup (the main router is router A and if there is no connection to internet then Router B will be used)?

Is there any reason why you cannot have a "normal":
Router A 192.168.0.1/24
Router B 192.168.0.254/24
PC's 192.168.0.2-192.168.0.253/24

Or:
Router A 192.168.0.1/22
Router B 192.168.1.1/22
PC's any in 192.168.2.0/22

Maybe if you try expanding on your requisites (i.e. what you expect the setup to be doing) a simpler solution (compared to doubling the NIC's on the PC's) can be found.
 
enricosm60
just joined
Topic Author
Posts: 23
Joined: Tue Nov 14, 2023 11:22 pm
Location: Panama

Re: connect a switch to two routers

Wed Jun 19, 2024 1:17 am

Hello Jaclaz,
Tks for the info. Well I have to explain better and include all the picture. So all the computers connected to the switch should communicate locally to all the routers and servers and also all of them will access the internet only using Router A (main Gateway). At the same time each server can access the internet only from the router connected to it.
Attached a more explanatory diagram.
The idea behind this is to have for each computer / laptop connected to the switch only one cable / NIC to accomplish the above; so any computer connected to the switch will have internet from Router A and at the same time will be able to access locally either Server A or Server B.
Hope This will explain better my goal.
Image
You do not have the required permissions to view the files attached to this post.
 
jaclaz
Forum Guru
Forum Guru
Posts: 2101
Joined: Tue Oct 03, 2023 4:21 pm

Re: connect a switch to two routers

Wed Jun 19, 2024 11:20 am

Yep, I understand, still a computer with IP address (static or assigned through DHCP server) in the 192.168.100.0/24 range won't be able to reach 192.168.0.1 (or 192.168.88.1) without some routing happening between them.
So the question remains, is there any reason why you cannot have either a "wider" netmask or a single /24 subnet in your setup?
Once you have such a (simpler) setup working, you can complicate it as much as you want with firewall rules and/or VLANs.

Please follow me:
Router A: 192.168.0.1/24
PC1 192.168.0.10/24 with Gateway 192.168.0.1
PC2 192.168.0.20/24 with Gateway 192.168.0.1
PC3 192.168.0.30/24 with Gateway 192.168.0.1
Server A: 192.168.0.2/24 Gateway 192.168.0.1
Router B: 192.168.0.254/24
Server B: 192.168.0.253/24 Gateway 192.168.0.254

PC's 1-3 and server A will access internet through Router A (Gateway 192.168.0.1)
Server B will access internet through Router B (Gateway 192.168.0.254)[1]
Any PC can connect to any other device in the (same) subnet[2].

What is the reason (if any) why such a scheme won't do for your *needs*?

[1] if you want - you can restrict access to the internet of Router B to only Server B and also prevent server B to access router A, this may depend on the exact make/models of routers A and B, that you should specify
[2] as well you can later add any kind of restriction
 
enricosm60
just joined
Topic Author
Posts: 23
Joined: Tue Nov 14, 2023 11:22 pm
Location: Panama

Re: connect a switch to two routers

Thu Jun 20, 2024 8:30 pm

Hello JACLAZ,
Tks for the hint.

So if I got this right, the trick is to have all the devices on the same subnet (192.168.0.0/24) and each router with its own gateway IP; then set on each device the desired gateway IP for internet access (router A or router B) and at the same time able to communicate locally to any device having only one eth NIC on each device.

One more thing... I have setup on each router it's own WireGuard VPN, but I think this is no an issue.

Well I will try this network config this weekend and I will you know.

Tks again
 
jaclaz
Forum Guru
Forum Guru
Posts: 2101
Joined: Tue Oct 03, 2023 4:21 pm

Re: connect a switch to two routers

Thu Jun 20, 2024 9:24 pm

Yep, the basics of ARP are explained here:
https://www.geeksforgeeks.org/how-addre ... arp-works/
essentially since all devices are in the same network, all devices can be reached by any other device "directly", this is layer 2, everything is as fast as it can be.

For local devices there is then no routing happening, if you introduce VLANs (if actually this separation is needed) a managed switch (like the RB260GS) can provide the required features allowing to separate, filter and distribute traffic:
viewtopic.php?t=143620