I am looking for a solution for the following Problem:
I have a hardware which is located in my private network and that sends out requests via HTTP to an IP and Port (i.e. 1.1.1.1:80) on the internet. The IP-Address and Port are fixed in the firmware of the hardware and there is no possibility for me to change this setting. Now, I need the HTTP Requests to be directed to a different IP-Address and Port of my choosing (i.e. 2.2.2.2:8080).
I figured that this should be possible using a router and was wondering if RouterOS can be configured to redirect the packages accordingly?
Let me add some thoughts myself.
First I try to concentrate on the rewriting of the IP-Address which is essential. If the port cannot be rewritten, I can deal with this problem on the receiving host.
Looking though the MikroTik Manuals, I found the manual for Destination-NAT which seems to be what I need. The problem is, that this type of NAT is usually used the other way around to forward packages from the internet to a local receiver IP. Is it possible to use this feature for the other direction?
A couple of concerns come into mind:
The destination address is not the address of any of the routers interfaces. Is that a problem? Could we maybe add this IP as a virtual router interface?
The direction is reversed. Does the MikroTik have the direction (outside → inside) fixed, or would this work the other way around aswell?
You’re overthinking it. Your rule translated to English says: “if a packet with destination 1.1.1.1 happens to come to router, change its destination to 2.2.2.2”. And that’s it. It does not care how the packet gets to router, from which interface, or where the destination address is, if it’s on router itself or somewhere else, none of that. In other other words, it will work fine. Add dst-port= and to-ports= and you’re done.