I’m using a webserver on my lan which is accessible from the internet, but I’m unable to access it locally. I’ve set up a hairpin NAT but I can’t seem to get it working still.
Here’s my config:
Local address space: 192.168.0.0/24
Webserver IP: 192.168.0.248
WAN interface: ether1
LAN interface: bridge1
I had exactly same issue when accessing home server by DNS name.
First I was using static DNS but I must use port in browsers and there were issues with some mobile browsers.
So I started to use masquerade for LAN access instead and everything is working perfect.
(Only one small side effect - all accesses from LAN will show as your router IP only.)
Try this settings modified for your setup (replace xxx.xxx.xxx.xxx by your public IP), it is working fine for me.
(Also check if there is not left any static DNS on router for your webserver.)
0 ;;; Common masquerade
chain=srcnat action=masquerade out-interface=ether1 log=no log-prefix=""
1 ;;; WAN to webserver 80
chain=dstnat action=dst-nat to-addresses=192.168.0.248 to-ports=80 protocol=tcp
dst-address=xxx.xxx.xxx.xxx dst-port=80 log=no log-prefix=""
2 ;;; WAN to webserver 25
chain=dstnat action=dst-nat to-addresses=192.168.0.248 to-ports=25 protocol=tcp
dst-address=xxx.xxx.xxx.xxx dst-port=25 log=no log-prefix=""
3 ;;; LAN to webserver
chain=srcnat action=masquerade protocol=tcp src-address=192.168.0.0/24 dst-address=192.168.0.248
log=no log-prefix=""
All variants of srcnat rules do not work on my MT network (ROS v6.29). Strange and not logical but that’s how it is. Only rule that works for me is:
add action=dst-nat chain=dstnat comment="masquerade QQQ from local net" dst-address=\
WAN-IP dst-port=WAN-natted-port protocol=tcp src-address=192.168.88.0/24 to-addresses=\
LAN-IP to-ports=LAN-Port
Substitute WAN-IP with your external gateway IP, WAN-natted-port with the external (Inet) port you used in the dsnat rule for portforwarding, src-address with the local address space you are using (watch out when using vlans), to-address with the local server IP and LAN-Port with the port you are using.
I doens’t have to be the top nat-rule. I put these rules right below the portforwarding rule.