Hello all,
I have a TP-Link Archer AX23 which I'm setting up as a subnet. My ISP router is dog water for firewall.
My network is configured as such:
ISP Router forwarding 443, and a few other ports, to the OpenWrt router, and the OpenWrt router is further forwarding those ports to the system hosting the relevant service. OpenWrt will also manage the NAT loopback.
The reason I'm writing this post is I haven't been able to find a straight forward answer on how to configure this using the LuCl UI and with that said someone else might find this helpful in the future, including myself.
My Issue
I'm rustier than a mining museum's outdoor equipment exhibit. I have Let's Encrypt certificates on the service in question, so just using local routing isn't an option - wrong IP for the certificate.
For the NAT loopback, I think these are the settings I need to provide in the LuCI UI under Network -> Firewall -> Port Forwards. Regular port forward is simple and I haven't set it up yet. Trying to get the rule for the subnet done first. Technically there's a subnet off of this one via virtual machines.
General Settings Tab:
Source Zone: LAN
External Port: 443
Destination Zone: WAN
Internal Address: 192.168.1.220
Internal Port: 443
Advanced Tab:
I only want to redirect traffic from one of my "cloud" VMs so I put the subnet they are all apart of.
Source IP Address: 192.168.1.0/24
External IP address:
Enable NAT Loopback: Checked
Loopback Source IP: Use External IP address
Reflection Zones: LAN
Everything else should be default.
I have tested this and it seems to be working as expected on my Windows laptop connected to the router via WiFi, however, the systems I intended this for are not able to use the NAT loopback. I took a pcap/tcpdump while attempting and I noticed that there were issues with some of the packets. Essentially it went like this:
client to openwrt A record
client to openwrt AAAA record
openwrt to client A record with public IP
openwrt to client AAAA record with public IP
client (private IP) SYN to server( public IP )
server( private IP) SYN, ACK to client (private IP.)
client ( private IP ) ICMP to server ( private IP ) destination unreachable ( host administratively prohibited )
client (Private IP) SYN to server ( public IP ) tcp retransmission
server( private IP ) SYN, ACK to client ( private IP ) tcp retransmission
So I started looking around and found that OpenWrt should be rewriting the IP in the Source from the Private IP in the SYN ACK to the Private IP that the request was sent to. So I checked the port forward and there was nowhere to set a rewrite address. I looked around and found: Network -> Firewall -> NAT Rules. Clicked the Add button.
I created the following NAT rule
General Tab
Protocol: TCP
Outbound Zone: LAN
Source Address: 192.168.1.220
Source Port: 443
Destination Address: 192.168.1.0/24
Action: SNAT - rewrite source ip
Rewrite IP Address:
Rewrite Port: do not rewrite
I've tried putting br-lan into promiscuous mode. I tried following this post ( NAT Loopback (Hairpin) isn't working: No rewriting Occuring OpenWrt 23.05.2 - #8 by securecryptomining ) without any success. I didn't bother with the script to run tcpdump on boot since this seemed to only work as a side effect of tcpdump putting the device into promiscuous mode. I did try tcpdump incase promiscuous mode wasn't enough out of sheer desperation. I'm out of ideas.
/etc/config/firewall
config redirect
option dest 'wan'
option target 'DNAT'
option name 'pkg NAT loopback'
option src 'lan'
option src_ip '192.168.1.0/24'
option src_dip '<public ip>'
option src_dport '443'
option dest_ip '192.168.1.220'
option dest_port '443'
option reflection_src 'external'
list reflection_zone 'lan'
config nat
list proto 'tcp'
option src '*'
option src_ip '192.168.1.220'
option src_port '443'
option dest_ip '192.168.1.0/24'
option target 'SNAT'
option snat_ip '<public ip>'
I overwrote the pcap with the DNS query in it, so it just uses cache now.
14 2.987014 192.168.1.222 <Public IP> TCP 74 49561 → 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM TSval=533513 TSecr=0 WS=128
15 2.987678 192.168.1.220 192.168.1.222 TCP 74 443 → 49561 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=64 SACK_PERM TSval=2236033172 TSecr=533513
16 2.987758 192.168.1.222 192.168.1.220 ICMP 102 Destination unreachable (Host administratively prohibited)
18 3.989998 192.168.1.222 <Public IP> TCP 74 [TCP Retransmission] 49561 → 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM TSval=534516 TSecr=0 WS=128
19 3.990690 192.168.1.220 192.168.1.222 TCP 74 [TCP Retransmission] 443 → 49561 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=64 SACK_PERM TSval=2236033172 TSecr=534516
20 3.990744 192.168.1.222 192.168.1.220 ICMP 102 Destination unreachable (Host administratively prohibited)
24 5.994064 192.168.1.222 <Public IP> TCP 74 [TCP Retransmission] 49561 → 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM TSval=536520 TSecr=0 WS=128
25 5.994772 192.168.1.220 192.168.1.222 TCP 74 [TCP Retransmission] 443 → 49561 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=64 SACK_PERM TSval=2236033172 TSecr=536520