I have LAN and 2 internet gateways - Mikrotiks CCR.
One of the computers in LAN I want to make NAT 1:1 to public IP . The public IP is routed to IGW2, so all trafic from internet to the computer public IP comes through IGW2. But trafic FROM the computer can be sent by both IGWs.
Everything works fine, when packet is sent by IGW2, there it is NATted to public IP, then answer comes back to IGW and it is NATted back to local IP. It works fine.
But problem is, when packet is sent by IGW1, there it is NATted, answer will come to IGW2. Then IGW2 sent the packet back to the internet, it will make no NAT. The packet is not going to the IP FIREWALL NAT.
When I ping from the computer to 178.217.148.40, in log on IGW2 I can see, packet are received from 178.217.148.40, but they are sent back to internet interface without any NAT.
When I added log rule on the 1st place to the NAT table, I can see, packets are not going to the NAT table anyway.
22:31:06 firewall,info forward: in:vlan503-Inet out:vlan503-Inet, src-mac 44:f4:77:9e:5f:f8, proto ICMP (type 0, code 0), 178.217.148.40->94.124.109.71, len 56
22:31:07 firewall,info forward: in:vlan503-Inet out:vlan503-Inet, src-mac 44:f4:77:9e:5f:f8, proto ICMP (type 0, code 0), 178.217.148.40->94.124.109.71, len 56
The way NAT works is that the router keeps a database of open sessions. That’s how it can route the return packets to correct destinations. Now the session is in IGW1 and when IGW2 receives a return packet it has no idea what to do with it. AFAIK there is no way to sync this information between the routers.
Why do you want to source the packets from IGW1 with the IP address of IGW2? The solution is to let IGW1 have its own public IP address. It can be dynamic, it doesn’t matter. That way all traffic going through IGW1 will use the same return path. Only traffic originating from the internet, destined to the static public IP address, will go through IGW2.
Yes, that’s what I supposed … but is there any way, how to switch off this behaviour? I just want NAT 1:1 … change source or destination IP of packets exactly 1:1 and not check, if the session is opened or not.
I think you have a routing problem in IGW2, the route for 94.124.109.71 is pointing back to internet.
Setup an interface where this IP address or its subnet is local to the router. Could be a bridge without any ports.
(often termed a Loopback in other routers)