[v6] dstnat not applying anymore? [solved with hairpin NAT]

Son of a *****.

Yes, I’ve been trying to connect to my external IP from within my LAN this whole time. I did NOT know it mattered whether I was connecting from within LAN or not (in this case) – that has never been something I’ve had to contend with while port-forwarding in the past, which I guess is because it was abstracted away from me on other platforms/devices. In hindsight, of course that totally explains why I can see my service from other websites but not from a browser on a device connected to the same LAN.

I just tested the external IP and open port from another internet connection, and yes, it resolves to the correct service as expected. I’m truly sorry that I wasn’t explicit about which network service requests from originating from! That’s just not something I would have even considered otherwise.

After some googling, and reading https://help.mikrotik.com/docs/display/ROS/NAT#NAT-HairpinNAT, http://forum.mikrotik.com/t/hairpin-nat-the-easy-way/146718/1 and watching https://youtu.be/_kw_bQyX-3U?si=1pRgSGSC0UcI-ylO, I setup a very basic NAT rule to allow local connections to use my external IP address. Which worked! Then I added a couple others to test, and they work as well! Here are my working settings:


# sep/05/2023 12:48:07 by RouterOS 6.49.8
# software id = 45F5-4C1D
#
# model = RB760iGS
# serial number = <REDACTED>
/interface bridge
add admin-mac=48:A9:8A:18:B7:3F auto-mac=no comment=defconf name=bridge
/interface bonding
add name=bonding1 slaves=ether1,ether2
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp disabled=no interface=bridge name=defconf
/interface bridge port
add bridge=bridge comment=defconf disabled=yes interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=sfp1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=bonding1 list=WAN
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
    192.168.88.0
/ip dhcp-client
add comment=defconf disabled=no interface=bonding1 use-peer-dns=no
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
    192.168.88.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,1.0.0.1,8.8.8.8
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall address-list
add address=<REDACTED> list=WAN_IP
add address=192.168.88.253 list=SERVER
/ip firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment=HairpinNAT dst-address-list=SERVER \
    out-interface-list=LAN protocol=tcp src-address=192.168.88.0/24
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
add action=dst-nat chain=dstnat comment=Dev.HTTP dst-address-list=WAN_IP \
    dst-port=8080 protocol=tcp to-addresses=192.168.88.253
add action=dst-nat chain=dstnat comment=HTTP dst-address-list=WAN_IP \
    dst-port=80 protocol=tcp to-addresses=192.168.88.253
add action=dst-nat chain=dstnat comment=HTTPS dst-address-list=WAN_IP \
    dst-port=443 protocol=tcp to-addresses=192.168.88.253
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set api disabled=yes
set winbox address=192.168.88.0/24
/system clock
set time-zone-name=America/Los_Angeles
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

Thank you very much for your help! I’ll make some edits to the OP containing what I learned and how to solve this – partially for my reference, and partially in-case anybody else stumbles here. Otherwise, feel free to lock this thread or do whatever it is you guys generally do.

I noticed there was some debate on the proper way and the various methods to accomplish this. If there’s a simpler or more complete method than I’ve chosen that might be more useful in my case, please let me know.

Thanks again!