I would have thought this would have been a common requirement, especially when connecting legacy or OEM equipment such as fillers and packers to a supervisory network.
Consider multiple machines each with devices having the same IP
It is not possible to change these IPs - (OEM equipment or validation etc.)
It is not possible to add a NAT device or change any network configurations for the same reason
But you wish to monitor or in some way connect to this equipment from a common supervisory network
Below is one solution
I added the ability for select devices ( with the same IP) to communicate with their counterparts (with the same IP)
It’s a work in progress, but it does work. I think I could make more use of lists etc.
Acknowledgement to Dan Schnur for his valuable assistance - Thank you Dan
Comments / Ideas ?
/ip address
# 10.10.10.2 will be the IP of the router from the PC
add address=10.10.10.2/24 interface=ether1
add address=10.10.10.21/24 interface=ether1
add address=10.10.10.22/24 interface=ether1
add address=10.10.10.23/24 interface=ether1
add address=10.10.10.24/24 interface=ether1
add address=10.10.10.31/24 interface=ether1
add address=10.10.10.32/24 interface=ether1
add address=10.10.10.33/24 interface=ether1
add address=10.10.10.34/24 interface=ether1
add address=10.10.10.41/24 interface=ether1
add address=10.10.10.42/24 interface=ether1
add address=10.10.10.43/24 interface=ether1
add address=10.10.10.44/24 interface=ether1
add address=192.168.1.1 interface=ether2
add address=192.168.1.1 interface=ether3
add address=192.168.1.1 interface=ether4
# List Of Stations that may comunicate with eachother
/ip firewall address-list
add address=10.10.10.22 list=Stations
add address=10.10.10.32 list=Stations
add address=10.10.10.42 list=Stations
# Mark Incomming Packets From Ether1 with a Connection Mark representing the desired outgoing port number
/ip firewall mangle
add action=mark-connection chain=prerouting dst-address=10.10.10.21 in-interface=ether1 new-connection-mark=PORT2 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.22 in-interface=ether1 new-connection-mark=PORT2 passthrough=yes comment="15"
add action=mark-connection chain=prerouting dst-address=10.10.10.23 in-interface=ether1 new-connection-mark=PORT2 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.24 in-interface=ether1 new-connection-mark=PORT2 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.31 in-interface=ether1 new-connection-mark=PORT3 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.32 in-interface=ether1 new-connection-mark=PORT3 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.33 in-interface=ether1 new-connection-mark=PORT3 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.34 in-interface=ether1 new-connection-mark=PORT3 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.41 in-interface=ether1 new-connection-mark=PORT4 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.42 in-interface=ether1 new-connection-mark=PORT4 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.43 in-interface=ether1 new-connection-mark=PORT4 passthrough=yes
add action=mark-connection chain=prerouting dst-address=10.10.10.44 in-interface=ether1 new-connection-mark=PORT4 passthrough=yes
# Mark Incomming Packets from Ether 2 3 and 4 with a Connection Mark representing the port it is comming from
# Station to Master (dst-address-list=!Stations)
add action=mark-connection chain=prerouting connection-state=new dst-address-list=!Stations in-interface=ether2 new-connection-mark=PORT2 passthrough=yes comment="11"
add action=mark-connection chain=prerouting connection-state=new dst-address-list=!Stations in-interface=ether3 new-connection-mark=PORT3 passthrough=yes
add action=mark-connection chain=prerouting connection-state=new dst-address-list=!Stations in-interface=ether4 new-connection-mark=PORT4 passthrough=yes
# Station to Station (dst-address-list=Stations)
add action=mark-connection chain=prerouting connection-state=new dst-address-list=Stations in-interface=ether2 new-connection-mark=STATION2 passthrough=yes comment="21"
add action=mark-connection chain=prerouting connection-state=new dst-address-list=Stations in-interface=ether3 new-connection-mark=STATION3 passthrough=yes
add action=mark-connection chain=prerouting connection-state=new dst-address-list=Stations in-interface=ether4 new-connection-mark=STATION4 passthrough=yes
# Copy Connection Marks to Routing Marks
add action=mark-routing chain=prerouting dst-address=10.10.10.22 new-routing-mark=PORT2 passthrough=no comment="25"
add action=mark-routing chain=prerouting dst-address=10.10.10.32 new-routing-mark=PORT3 passthrough=no comment="21"
add action=mark-routing chain=prerouting dst-address=10.10.10.42 new-routing-mark=PORT4 passthrough=no
add action=mark-routing chain=prerouting connection-mark=PORT2 new-routing-mark=PORT2 passthrough=no comment="15"
add action=mark-routing chain=prerouting connection-mark=PORT3 new-routing-mark=PORT3 passthrough=no
add action=mark-routing chain=prerouting connection-mark=PORT4 new-routing-mark=PORT4 passthrough=no
# DST NAT is performed first
/ip firewall nat
add action=dst-nat chain=dstnat dst-address=10.10.10.21 to-addresses=192.168.1.41
add action=dst-nat chain=dstnat dst-address=10.10.10.22 to-addresses=192.168.1.42 comment="16 and 26"
add action=dst-nat chain=dstnat dst-address=10.10.10.23 to-addresses=192.168.1.43
add action=dst-nat chain=dstnat dst-address=10.10.10.24 to-addresses=192.168.1.44
add action=dst-nat chain=dstnat dst-address=10.10.10.31 to-addresses=192.168.1.41
add action=dst-nat chain=dstnat dst-address=10.10.10.32 to-addresses=192.168.1.42 comment="22"
add action=dst-nat chain=dstnat dst-address=10.10.10.33 to-addresses=192.168.1.43
add action=dst-nat chain=dstnat dst-address=10.10.10.34 to-addresses=192.168.1.44
add action=dst-nat chain=dstnat dst-address=10.10.10.41 to-addresses=192.168.1.41
add action=dst-nat chain=dstnat dst-address=10.10.10.42 to-addresses=192.168.1.42
add action=dst-nat chain=dstnat dst-address=10.10.10.43 to-addresses=192.168.1.43
add action=dst-nat chain=dstnat dst-address=10.10.10.44 to-addresses=192.168.1.44
# Not Sure If Masquerade is required or not
# add action=masquerade chain=srcnat out-interface=ether2
# add action=masquerade chain=srcnat out-interface=ether3
# add action=masquerade chain=srcnat out-interface=ether4
# SRC NAT is performed second
# Station to Master
add action=src-nat chain=srcnat connection-mark=PORT2 out-interface=ether1 src-address=192.168.1.41 to-addresses=10.10.10.21
add action=src-nat chain=srcnat connection-mark=PORT2 out-interface=ether1 src-address=192.168.1.42 to-addresses=10.10.10.22 comment="13"
add action=src-nat chain=srcnat connection-mark=PORT2 out-interface=ether1 src-address=192.168.1.43 to-addresses=10.10.10.23
add action=src-nat chain=srcnat connection-mark=PORT2 out-interface=ether1 src-address=192.168.1.44 to-addresses=10.10.10.24
add action=src-nat chain=srcnat connection-mark=PORT3 out-interface=ether1 src-address=192.168.1.41 to-addresses=10.10.10.31
add action=src-nat chain=srcnat connection-mark=PORT3 out-interface=ether1 src-address=192.168.1.42 to-addresses=10.10.10.32
add action=src-nat chain=srcnat connection-mark=PORT3 out-interface=ether1 src-address=192.168.1.43 to-addresses=10.10.10.33
add action=src-nat chain=srcnat connection-mark=PORT3 out-interface=ether1 src-address=192.168.1.44 to-addresses=10.10.10.34
add action=src-nat chain=srcnat connection-mark=PORT4 out-interface=ether1 src-address=192.168.1.41 to-addresses=10.10.10.41
add action=src-nat chain=srcnat connection-mark=PORT4 out-interface=ether1 src-address=192.168.1.42 to-addresses=10.10.10.42
add action=src-nat chain=srcnat connection-mark=PORT4 out-interface=ether1 src-address=192.168.1.43 to-addresses=10.10.10.43
add action=src-nat chain=srcnat connection-mark=PORT4 out-interface=ether1 src-address=192.168.1.44 to-addresses=10.10.10.44
# Station to Station
add action=src-nat chain=srcnat connection-mark=STATION2 src-address=192.168.1.42 to-addresses=10.10.10.22 comment="23"
add action=src-nat chain=srcnat connection-mark=STATION3 src-address=192.168.1.42 to-addresses=10.10.10.32 comment="27"
add action=src-nat chain=srcnat connection-mark=STATION4 src-address=192.168.1.42 to-addresses=10.10.10.42
/ip route
add gateway=10.10.10.1 comment="14"
# Route Packets to Correct Port
add distance=1 dst-address=192.168.1.0/24 gateway=ether2 routing-mark=PORT2 comment="18 and 28"
add distance=1 dst-address=192.168.1.0/24 gateway=ether3 routing-mark=PORT3 comment="24"
add distance=1 dst-address=192.168.1.0/24 gateway=ether4 routing-mark=PORT4
# End