Page 1 of 1

Client wants to access NAT'd web server from inside LAN using WAN IP

Posted: Mon Oct 29, 2018 5:06 pm
by isaacgrover
Good morning from Wisconsin,

One of our MSP clients wants to access his company's website, which is hosted on a VM in the same LAN, using the WAN IP address. To be clear, the website is accessible externally from the WAN IP address on port 80, and we have been unable to convince him to use the FQDN instead, which resolves correctly to the LAN IP address when in the LAN and the WAN IP address when outside the LAN.

Would this somehow be possible via filter and dst-nat rules in the nat table?

Thank you in advance,
Isaac Grover

Re: Client wants to access NAT'd web server from inside LAN using WAN IP

Posted: Mon Oct 29, 2018 5:09 pm
by Omar007
I'm fairly sure this is exactly the case you'd set up a Hairpin NAT for.
https://wiki.mikrotik.com/wiki/Hairpin_NAT

Re: Client wants to access NAT'd web server from inside LAN using WAN IP

Posted: Mon Oct 29, 2018 5:13 pm
by xvo
Try googling “hairpin nat” :)

Re: Client wants to access NAT'd web server from inside LAN using WAN IP  [SOLVED]

Posted: Mon Oct 29, 2018 5:16 pm
by Steveocee
Take what you need from this. Explains how to hairpin NAT, create the correct port forwards and can be adapted for dynamic or static WAN IP (plus some comedy phrases);
https://www.youtube.com/watch?v=_kw_bQyX-3U

Re: Client wants to access NAT'd web server from inside LAN using WAN IP

Posted: Mon Oct 29, 2018 8:58 pm
by isaacgrover
Hi steveocee,

The Youtube video nailed the solution for me. If Youtube ever yanks it though, here's the solution for future visitors:
- In /ip firewall nat, you need to create a rule in the srcnat chain that masquerades traffic from the internal LAN subnet to the same internal LAN subnet.
- Then in /ip firewall filter, change/create the appropriate port forward rule and instead of forwarding based on in-interface, forward based on dst-address.

Dear future visitor, if the Youtube video exists at the time you're reading this post, please go watch it - and don't do anything that will make your network go batshitcrazy! LOL

Make your day great,
Isaac