We have 3 ethernet ports each with own IP. Let’s say eth1=81.12.34.56, eth2=82.34.56.78 and eth3=192.168.0.3. And ip=88.34.56.78 is somewhere in Internet
The following behaviour needed:
When somebody send packet with destination 192.168.0.3:1111 via eth3 then packet changes its destination to 88.34.56.78 and source to 81.12.34.56 and leave router via eth1.
When somebody send packet with destination 82.34.56.78:1111 via eth2 then packet also changes its destination to 88.34.56.78 and source to 81.12.34.56 and leave router via eth1.
All connections established as described in 1 and 2 should work as bidirectional.
Thank you for the reply. But in my case destination address shold be changed also. How it can be solved by PBR or SRCNAT which were mentioned in your answer?
Basic changing of both source and destination is easy, just remember that dstnat happens first and then follows srcnat. So you first change destination from 192.168.0.3:1111 to 88.34.56.78 and then change source to 81.12.34.56 for these packets. You can no longer recognize them by original destination, but you’ll have to look for 88.34.56.78:1111.
But you didn’t write anything about routes, so it’s not possible to tell what will happen if you only add NAT rules. It’s likely that it won’t work, but impossible to say how exactly.