Community discussions

MikroTik App
 
iaraptisJack
just joined
Topic Author
Posts: 3
Joined: Wed May 27, 2020 4:29 pm

NAT on two different LAN

Wed May 27, 2020 4:37 pm

Hi

I have a PC Client 192.168.1.8 that has gateway a mikrotik 192.168.1.3 (eth2)
Mikrotik has on eth1 10.10.10.0/24 and has gateway another mikrotik 10.10.10.101

Mikrotik 10.10.10.101 uses on an interface the 192.168.1.0/24 network.
Is there a way to access PC Client 192.168.1.8 from 10.10.10.0/24 by using NAT or another way?
 
mrtrca
just joined
Posts: 9
Joined: Wed Dec 05, 2012 2:22 pm
Location: Turkey
Contact:

Re: NAT on two different LAN

Wed May 27, 2020 5:19 pm

Hi,
I think if you do masquerade without specifying out-interface.
/ip firewall nat add chain=srcnat src-address=192.168.1.0/24 action=masquerade
/ip firewall nat add chain=srcnat src-address=10.10.10.0/24 action=masquerade
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11151
Joined: Mon Dec 04, 2017 9:19 pm

Re: NAT on two different LAN

Wed May 27, 2020 5:53 pm

Hi

I have a PC Client 192.168.1.8 that has gateway a mikrotik 192.168.1.3 (eth2)
Mikrotik has on eth1 10.10.10.0/24 and has gateway another mikrotik 10.10.10.101

Mikrotik 10.10.10.101 uses on an interface the 192.168.1.0/24 network.
Is there a way to access PC Client 192.168.1.8 from 10.10.10.0/24 by using NAT or another way?
You can use a dst-nat rule at the first Mikrotik - from the second one, you connect to the address of the first one, and the first one forwards the packet to the PC. This is true for connections initiated in this direction (the client is the second Mikrotik, the server is the PC); in the opposite direction (PC as a client connecting to the second Mikrotik), you need a src-nat on the first Mikrotik, so that the responses from the second Mikrotik to the PC client would not end at its local LAN.

But you can also set up a route to 192.168.1.8/32 at the second Mikrotik via the first one, which will override the dynamically added route to the local subnet, but it means that you cannot use 192.168.1.8 on the second Mikrotik's LAN.
 
iaraptisJack
just joined
Topic Author
Posts: 3
Joined: Wed May 27, 2020 4:29 pm

Re: NAT on two different LAN

Fri May 29, 2020 12:00 pm

Hi

I have a PC Client 192.168.1.8 that has gateway a mikrotik 192.168.1.3 (eth2)
Mikrotik has on eth1 10.10.10.0/24 and has gateway another mikrotik 10.10.10.101

Mikrotik 10.10.10.101 uses on an interface the 192.168.1.0/24 network.
Is there a way to access PC Client 192.168.1.8 from 10.10.10.0/24 by using NAT or another way?
You can use a dst-nat rule at the first Mikrotik - from the second one, you connect to the address of the first one, and the first one forwards the packet to the PC. This is true for connections initiated in this direction (the client is the second Mikrotik, the server is the PC); in the opposite direction (PC as a client connecting to the second Mikrotik), you need a src-nat on the first Mikrotik, so that the responses from the second Mikrotik to the PC client would not end at its local LAN.

But you can also set up a route to 192.168.1.8/32 at the second Mikrotik via the first one, which will override the dynamically added route to the local subnet, but it means that you cannot use 192.168.1.8 on the second Mikrotik's LAN.
The route to 192.168.1.8/32 is a good solution.

About the solution with the dst-nat rule a have some questions: every set-up should be only in first mikrotik? (192.168.1.3 / 10.10.10.4). No need to set anything to the second one?


Thank you for your help
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11151
Joined: Mon Dec 04, 2017 9:19 pm

Re: NAT on two different LAN

Fri May 29, 2020 12:15 pm

every set-up should be only in first mikrotik? (192.168.1.3 / 10.10.10.4). No need to set anything to the second one?
Yes. The client on the second Mikrotik connects to 10.10.10.4 and all the handling needs to be done at the 10.10.10.4 'Tik.
 
iaraptisJack
just joined
Topic Author
Posts: 3
Joined: Wed May 27, 2020 4:29 pm

Re: NAT on two different LAN

Fri May 29, 2020 12:56 pm

[/quote]
Yes. The client on the second Mikrotik connects to 10.10.10.4 and all the handling needs to be done at the 10.10.10.4 'Tik.
[/quote]

Ok but i want from the LAN 10.10.10.0/24 to connect to 192.168.1.8 . How the second mikrotik will know to forward the packets to 10.10.10.4?
In the case of static route its obvious but in other case i don't understand how they will communicate
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11151
Joined: Mon Dec 04, 2017 9:19 pm

Re: NAT on two different LAN

Fri May 29, 2020 1:10 pm

Ok but i want from the LAN 10.10.10.0/24 to connect to 192.168.1.8
It wasn't clear from your OP to that you want the client at the second Tik to connect to the address 192.168.1.8, it seemed to be sufficient that it reaches the server "somehow".

So if you don't mind excluding 192.168.1.8 from use on the second Tik, the route is the easiest solution; otherwise you may use two dst-nat rules, one on each Tik, and the rule on the second Tik may act only on packets from the IP address if the client.

But I forgot to write that if the client's address is in 192.168.1.x too, you have to make the second Tik respond to ARP requests for 192.168.1.8. This can be done using /interface bridge nat rules (and then you can add the exceptional route), or you may attach 192.168.1.8 as own address of the second Tik and use the two dst-nat rules.

Who is online

Users browsing this forum: aoakeley, ech, Techsystem and 24 guests