Community discussions

MikroTik App
 
ik3umt
Member Candidate
Member Candidate
Topic Author
Posts: 295
Joined: Tue Jul 08, 2014 3:58 pm

Managing two separate subnet with same class addresses

Wed May 29, 2019 10:12 am

Is it possible to manage two LAN having each the same IP subnet both containing machines with same ip address ?

Image

I would say NO, but I'm not aware if Ros has some obscure feature......
I could use netmap to addressing two different subnet , but how to know on wich target machines ?
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2880
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Managing two separate subnet with same class addresses

Wed May 29, 2019 10:59 am

Why?
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: Managing two separate subnet with same class addresses

Wed May 29, 2019 11:08 am

Why not? ;) It's of course better to not have something like this, but if it already happened and it's not possible to change it...

Netmap with some virtual subnets is good first step. Next one would be two routing tables, one for each subnet on different interfaces. And finally mangle rules in prerouting to choose the right routing table based on which virtual subnet is destination.
 
ik3umt
Member Candidate
Member Candidate
Topic Author
Posts: 295
Joined: Tue Jul 08, 2014 3:58 pm

Re: Managing two separate subnet with same class addresses

Wed May 29, 2019 11:43 am

Sob, How can I define a virtual subnet to the real one and routing through the right interface ?
I suppose each ethernet has not to be configured with an ip address...
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19371
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Managing two separate subnet with same class addresses

Wed May 29, 2019 5:03 pm

Why?
So Sob can show off his MT networking skills ;-)
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: Managing two separate subnet with same class addresses

Thu May 30, 2019 12:00 am

Simple example showing how to set up access from outside:

First some addresses (*):
/ip address
add address=192.168.0.1/24 interface=test1
add address=192.168.0.1/24 interface=test2
Routes in two different routing tables:
/ip route
add dst-address=192.168.0.0/24 gateway=test1 routing-mark=net1
add dst-address=192.168.0.0/24 gateway=test2 routing-mark=net2
Mangle rules (packets to virtual 192.168.91.x will get "net1" routing mark, and packets to virtual 192.168.92.x will get "net2" routing mark):
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address=192.168.91.0/24 new-routing-mark=net1
add action=mark-routing chain=prerouting dst-address=192.168.92.0/24 new-routing-mark=net2
Map virtual networks to real ones:
/ip firewall nat
add action=netmap chain=dstnat dst-address=192.168.91.0/24 to-addresses=192.168.0.0/24
add action=netmap chain=dstnat dst-address=192.168.92.0/24 to-addresses=192.168.0.0/24
Small fix for when this router is not default gateway for both networks:
/ip firewall nat
add action=masquerade chain=srcnat out-interface=test1
add action=masquerade chain=srcnat out-interface=test2
(*) Same address and network on two interfaces like this is of course wrong. For this example, it could be maybe a little less wrong with /32 netmask.

This example also shows only the basic idea, the RB won't work as default gateway for both subnets. It could, but it would require additional connection marking. But since I don't know how exactly is everything connected, I won't bother with that now.
 
ik3umt
Member Candidate
Member Candidate
Topic Author
Posts: 295
Joined: Tue Jul 08, 2014 3:58 pm

Re: Managing two separate subnet with same class addresses

Thu May 30, 2019 2:31 am

I didn't know more interfaces can be configured with the same ip address and subnet , I thought this would mess up things.

It happens, rarely, but happens, you find a place having the same addressing i.e. for PC and for ip cameras or ip telephony, completely separated , each with its own switch (sometimes ip cameras network stand-alone without a router) and you're asked for managing both remtely......

Surely I'll give it a try !
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: Managing two separate subnet with same class addresses

Thu May 30, 2019 3:48 am

I thought it was clear that it does mess things up. :) The fact that to some extent it's possible to make it work doesn't change that it's wrong. If it's at all possible, the config should be changed into something clean, i.e. either join the networks correctly, or renumber some.
 
ik3umt
Member Candidate
Member Candidate
Topic Author
Posts: 295
Joined: Tue Jul 08, 2014 3:58 pm

Re: Managing two separate subnet with same class addresses

Thu May 30, 2019 12:53 pm

No, wait, I haven't undesrtood if two eth with the same ip address and class on the same routerboard is IMPOSSIBLE (don't work) or is WRONG (but works because of using interface names and routing marks).

Each LAN has it own gateway (not the routerboard).
 
savage
Forum Guru
Forum Guru
Posts: 1264
Joined: Mon Oct 18, 2004 12:07 am
Location: Cape Town, South Africa
Contact:

Re: Managing two separate subnet with same class addresses

Thu May 30, 2019 2:36 pm

Only way to do this without messing things up, is to use a VRF
 
alexioma
just joined
Posts: 6
Joined: Tue Jan 16, 2024 2:54 am

Re: Managing two separate subnet with same class addresses

Wed Apr 03, 2024 1:57 am

Hi there,

I'm currently researching a very similar solution for a setup where I have:
- a single CCR acting as main and unique router for a whole plant (ROS 7.14.2) configured with VLANs under bridge
- one CRS switch connected to the CCR (via trunk port) and also to other (18) "dev" subnets with identical topology (each subnet/vlan has 192.168.1.0/24 overlapping range)
- such subnets cannot change IP range and have a few devices that have static IPs (which may also be identical from one subnet to the other). These subnets do not need to reach internet or the mgmt vlan
- mgmt vlan must be able to reach all devices in the dev subnets / vlan with a unique IP such as:
-> A PC in the mgmt vlan (say 10.2.0.0/24) should be able to reach a PC (device IP is 192.168.1.10/24) in dev1 vlan via 10.2.1.10
-> A PC in the mgmt vlan should be able to reach a second PC (device IP is 192.168.1.10/24) in dev2 vlan via 10.2.2.10, and so on.

I understand the solution lies in a mix of mangle and netmap dstnat + possibly the use of VRFs but I fail to grasp the full setup.

Can you please assist with this setup? For sake of simplicity we might skip the VLAN (with additional switch part) and focus on a simpler solution based on the diagram at the beginning of the post.

Thank you in advance.

UPDATE: found a working solution: here.

Who is online

Users browsing this forum: Semrush [Bot] and 92 guests