I’m digging around in an effort to get more of a firm grasp on appropriate setups for port forwarding. The current situation is using a HEX750 as my main router. I have a web server running Apache that I’d like to access both internally and externally. With my current setup I have it working, but I question if I have it set up in the most appropriate manner. I feel like Mikrotik gives you enough rope to hang yourself, so this has me interested in making sure that not only are things working but they are set up correctly. It’s also worth noting that I have a dynamic IP from my ISP, so I’ve found myself hesitant to just plug in my (current and of course temporary) IP into my rules since we all know that may inevitably change in the future.
Currently my forward rule list is as follows:
0 ;;; defconf: masquerade
chain=srcnat action=masquerade out-interface=ether1-WAN
1 ;;; Hairpin NAT
chain=srcnat action=masquerade src-address=192.168.0.0/24 dst-address=192.168.0.0/24
2 chain=dstnat action=dst-nat to-addresses=192.168.0.21 to-ports=443 protocol=tcp dst-address-type=local dst-port=443 log=no log-prefix=""
3 chain=dstnat action=dst-nat to-addresses=192.168.0.21 to-ports=80 protocol=tcp dst-address-type=local dst-port=80 log=no log-prefix=""
The curious part comes in with the fact that I do not have in-interface set. Many guides suggest to use this. Whenever I employ it, I lose connection to these services internally. Likewise, I also have dst-address-type=local set, which I’ve only managed to find on one guide so far, yet the other ~20 guides have neglected to mention this. Given the magnitude of folks not using dst-address-type=local and replying back that everything is working, it raises an eyebrow. I’m sure we all have different setups, but some of these cases did not sound complex at all and some suggested they were very similar to mine.
My understanding from dst-address-type=local is “Basically that means if the dst-address is “local” to the router (e.g. it is assigned to one of the interfaces on the router).” (quoted from another user on here). The server in question is not directly connected to the Mikrotik router. The only thing connected to the Mikrotik router is WAN (ether1) and LAN (ether2), where LAN/ether2 goes to a larger network switch. Perhaps I’m splitting hairs and that’s still considered directly connected, but the exact verbosity of that quote had me curious.
A video guide from another user that was linked here on the forums suggested the importance of setting in-interface, and even went as far as to say “without it you’ll have all sorts of routing problems.” I haven’t had much luck with setting in-interface and having things remain in working order, so there’s another eyebrow raise.
Lastly, I understood that the Hairpin NAT was to work cohesively with my forwarded ports, to the point I could just forward ports with dstnat as the vast majority of the documented examples provided and the hairpin would be the “gotcha” that makes them also work internally. Despite this, I’m still finding I need to tailor things a bit outside of what most examples provide (dst-address-type=local, lack of in-interface being set, etc). Perhaps this is par for the course with different setups, but like I said, I was curious enough to keep looking.
Anyway I guess I’m asking if someone here would have any advice for me as a pretty new Mikrotik user. I’m not really built to just “accept things as is” without understanding what they are doing. My current list of rules above seem to work fine (such as my web server working both internally and externally), but not having a firm grasp on the ‘why’ took me through many guides, and ultimately, here to ask.
Thanks ahead of time for any insight!