NAT Loopback on OpenWrt as bridge

Hello everybody.
My english is really bad, I hope you will understand me.

I have a modem from my ISP located upstream of my TP LINK WD9970 with OpenWrt 19.07.2 r10947-65030d81f3.

With a lot of effort I managed to get it working, but I can't reach my NAS with the public domain name from inside the LAN.

I believe that the nat loopback works properly but the browser returns the login page of the modem to which the TP-Link router is connected in bridged mode (normally not accessible from the outside) instead of the login page of my NAS.

From the WAN everything works fine.

I would not like to use OpenWrt Hostnames because then I could have problems with the functioning of some Google home mini devices connected to my Home Assistant installation.

My knowledge on the subject is really poor, where can I start to try to solve the problem?

Thank you.

The easiest way is to rebind the domain with LAN IP address using OpenWrt DNS:
https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#hostnames

1 Like

Thanks for the answer, but what you propose would be like adding a hostname in the luci interface.

This solution works well, but it creates problems in using google mini and home assistant.

Google home mini has the Google DNS hardcoded and always resolves the public domain name with my public ip address.

If I enter my public IP address in the browser, it returns my ISP's modem login page and not the nas login page.

If I type my public name with hostname set, the nas answers correctly, but unfortunately google home doesn't work like that.

Thanks for your help.

1 Like

You can try to simply hijack it:
https://openwrt.org/docs/guide-user/firewall/fw3_configurations/intercept_dns

1 Like

Keep in mind that NAT Loopback is utilizing router cpu resources for what would normally be intra-lan traffic. So accessing a NAS and downloading big files can impact the performance of the router, which I think you mistyped as I cannot find a tp-link wd9970. There is w9970, which is adsl modem/router, but not supported. Maybe it was W9980? It also has a weak cpu.

1 Like

In the Synolody DS216J NAS there is home assistant installed and the only purpose of the NAT Loopback is to make the android app and the google home mini work within the lan, pointing to the public name.

For all other situations I can access the internal name nas.lan

Sorry, it's an old TP-LINK TD-W8970

Alright, then let's have a look at the configurations and running settings.

Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board; \
uci export network; \
uci export dhcp; uci export firewall; \
head -n -0 /etc/firewall.user; \
iptables-save -c; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
ls -l  /etc/resolv.* /tmp/resolv.*; head -n -0 /etc/resolv.* /tmp/resolv.*
1 Like

Thanks for your help. I hope I have hidden all private data

ubus call system board; \

{
        "kernel": "4.14.171",
        "hostname": "OpenWrt",
        "system": "xRX200 rev 1.2",
        "model": "TP-LINK TD-W8970",
        "board_name": "tplink,tdw8970",
        "release": {
                "distribution": "OpenWrt",
                "version": "19.07.2",
                "revision": "r10947-65030d81f3",
                "target": "lantiq/xrx200",
                "description": "OpenWrt 19.07.2 r10947-65030d81f3"
        }
}

uci export network; \

package network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'xxxx:xxxx:xxxx::/48'

config atm-bridge 'atm'
        option vpi '1'
        option vci '32'
        option encaps 'llc'
        option payload 'bridged'
        option nameprefix 'dsl'

config dsl 'dsl'
        option annex 'a'
        option tone 'av'
        option ds_snr_offset '0'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.XX.1'
        list dns '8.8.8.8'
        list dns '8.8.4.4'

config interface 'wan'
        option proto 'static'
        option netmask '255.255.255.0'
        list dns '8.8.8.8'
        list dns '8.8.4.4'
        option ipaddr '192.168.1.2'
        option gateway '192.168.1.1'
        option ifname 'eth0.2'

config device 'wan_dsl0_dev'
        option name 'dsl0'
        option macaddr 'XX:XX:XX:XX:XX:XX'

config interface 'wan6'
        option ifname '@wan'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option vid '1'
        option ports '6t 5 0 2'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option vid '2'
        option ports '6t 4'

config interface 'guest'
        option proto 'static'
        option ipaddr '192.168.YY.1'
        option netmask '255.255.255.0'

config interface 'IoT'
        option proto 'static'
        option ipaddr '192.168.ZZ.1'
        option netmask '255.255.255.0'

uci export dhcp; uci export firewall; \

package dhcp

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option localservice '1'
        option confdir '/tmp/dnsmasq.d'

config dhcp 'lan'
        option interface 'lan'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        option ra_management '1'
        option start '150'
        option limit '100'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config host
        option mac 'XX:XX:XX:XX:XX:XX'
        option dns '1'
        option name 'NAME'
        option duid 'XXXXXXXXXXXXXXXXXXXX'
        option ip '192.168.XX.XXX'

config dhcp 'guest'
        option start '100'
        option leasetime '12h'
        option limit '150'
        option interface 'guest'

config dhcp 'IoT'
        option leasetime '12h'
        option interface 'IoT'
        option start '200'
        option limit '50'

config domain
        option ip '192.168.XX.107'
        option name 'EXTERNALNAME.DOMAIN.COM'

package firewall

config defaults
        option syn_flood '1'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'

config zone
        option name 'wan'
        list network 'wan'
        list network 'wan6'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fc00::/6'
        option dest_ip 'fc00::/6'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

config include
        option path '/etc/firewall.user'

config zone
        option name 'guest'
        option input 'REJECT'
        option forward 'REJECT'
        option output 'ACCEPT'
        option network 'guest'

config forwarding
        option dest 'wan'
        option src 'guest'

config rule
        option dest_port '53'
        option src 'guest'
        option name 'Guest DNS'
        option target 'ACCEPT'

config rule
        option dest_port '67-68'
        option name 'Guest DHCP'
        option target 'ACCEPT'
        list proto 'udp'
        option src 'guest'
        option src_port '67-68'

config zone
        option network 'IoT'
        option name 'IoT'
        option output 'ACCEPT'
        option input 'REJECT'
        option forward 'REJECT'

config forwarding
        option dest 'wan'
        option src 'IoT'

config forwarding
        option dest 'IoT'
        option src 'lan'

config rule
        option dest_port '53'
        option target 'ACCEPT'
        option name 'IoT DNS'
        option src 'IoT'

config rule
        option src_port '67-68'
        option src 'IoT'
        option name 'IoT DHCP'
        option target 'ACCEPT'
        option dest_port '67-68'
        list proto 'udp'

config rule
        option src 'IoT'
        option name 'Allow HOME ASSISTANT from IoT VLAN'
        option dest 'lan'
        list dest_ip '192.168.XX.107'
        option target 'ACCEPT'

config redirect
        option src 'wan'
        option name 'NGINX'
        option target 'DNAT'
        option dest_ip '192.168.XX.107'
        option dest 'lan'
        option dest_port '443'
        option src_dport '443'

config rule
        option src_port '5353'
        option src '*'
        option name 'Allow mDNS'
        option target 'ACCEPT'
        list dest_ip '224.0.0.251'
        option dest_port '5353'
        list proto 'udp'

head -n -0 /etc/firewall.user; \

# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.

# Internal uci firewall chains are flushed and recreated on reload, so
# put custom rules into the root chains e.g. INPUT or FORWARD or into the
# special user chains, e.g. input_wan_rule or postrouting_lan_rule.

iptables-save -c; \

 Generated by iptables-save v1.8.3 on Sun Oct  4 18:26:12 2020
*nat
:PREROUTING ACCEPT [10614:1675518]
:INPUT ACCEPT [2692:287534]
:OUTPUT ACCEPT [1563:124088]
:POSTROUTING ACCEPT [314:38557]
:postrouting_IoT_rule - [0:0]
:postrouting_guest_rule - [0:0]
:postrouting_lan_rule - [0:0]
:postrouting_rule - [0:0]
:postrouting_wan_rule - [0:0]
:prerouting_IoT_rule - [0:0]
:prerouting_guest_rule - [0:0]
:prerouting_lan_rule - [0:0]
:prerouting_rule - [0:0]
:prerouting_wan_rule - [0:0]
:zone_IoT_postrouting - [0:0]
:zone_IoT_prerouting - [0:0]
:zone_guest_postrouting - [0:0]
:zone_guest_prerouting - [0:0]
:zone_lan_postrouting - [0:0]
:zone_lan_prerouting - [0:0]
:zone_wan_postrouting - [0:0]
:zone_wan_prerouting - [0:0]
[10683:1679578] -A PREROUTING -m comment --comment "!fw3: Custom prerouting rule chain" -j prerouting_rule
[4921:609937] -A PREROUTING -i br-lan -m comment --comment "!fw3" -j zone_lan_prerouting
[547:31722] -A PREROUTING -i eth0.2 -m comment --comment "!fw3" -j zone_wan_prerouting
[5215:1037919] -A PREROUTING -i wlan0-1 -m comment --comment "!fw3" -j zone_IoT_prerouting
[3802:321571] -A POSTROUTING -m comment --comment "!fw3: Custom postrouting rule chain" -j postrouting_rule
[87:9502] -A POSTROUTING -o br-lan -m comment --comment "!fw3" -j zone_lan_postrouting
[3488:283014] -A POSTROUTING -o eth0.2 -m comment --comment "!fw3" -j zone_wan_postrouting
[225:28909] -A POSTROUTING -o wlan0-1 -m comment --comment "!fw3" -j zone_IoT_postrouting
[225:28909] -A zone_IoT_postrouting -m comment --comment "!fw3: Custom IoT postrouting rule chain" -j postrouting_IoT_rule
[5215:1037919] -A zone_IoT_prerouting -m comment --comment "!fw3: Custom IoT prerouting rule chain" -j prerouting_IoT_rule
[0:0] -A zone_guest_postrouting -m comment --comment "!fw3: Custom guest postrouting rule chain" -j postrouting_guest_rule
[0:0] -A zone_guest_prerouting -m comment --comment "!fw3: Custom guest prerouting rule chain" -j prerouting_guest_rule
[87:9502] -A zone_lan_postrouting -m comment --comment "!fw3: Custom lan postrouting rule chain" -j postrouting_lan_rule
[0:0] -A zone_lan_postrouting -s 192.168.XX.0/24 -d 192.168.XX.107/32 -p tcp -m tcp --dport 443 -m comment --comment "!fw3: NGINX (reflection)" -j SNAT --to-source 192.168.XX.1
[0:0] -A zone_lan_postrouting -s 192.168.XX.0/24 -d 192.168.XX.107/32 -p udp -m udp --dport 443 -m comment --comment "!fw3: NGINX (reflection)" -j SNAT --to-source 192.168.XX.1
[4921:609937] -A zone_lan_prerouting -m comment --comment "!fw3: Custom lan prerouting rule chain" -j prerouting_lan_rule
[0:0] -A zone_lan_prerouting -s 192.168.XX.0/24 -d 192.168.1.2/32 -p tcp -m tcp --dport 443 -m comment --comment "!fw3: NGINX (reflection)" -j DNAT --to-destination 192.168.XX.107:443
[0:0] -A zone_lan_prerouting -s 192.168.XX.0/24 -d 192.168.1.2/32 -p udp -m udp --dport 443 -m comment --comment "!fw3: NGINX (reflection)" -j DNAT --to-destination 192.168.XX.107:443
[3488:283014] -A zone_wan_postrouting -m comment --comment "!fw3: Custom wan postrouting rule chain" -j postrouting_wan_rule
[3488:283014] -A zone_wan_postrouting -m comment --comment "!fw3" -j MASQUERADE
[547:31722] -A zone_wan_prerouting -m comment --comment "!fw3: Custom wan prerouting rule chain" -j prerouting_wan_rule
[63:3748] -A zone_wan_prerouting -p tcp -m tcp --dport 443 -m comment --comment "!fw3: NGINX" -j DNAT --to-destination 192.168.XX.107:443
[0:0] -A zone_wan_prerouting -p udp -m udp --dport 443 -m comment --comment "!fw3: NGINX" -j DNAT --to-destination 192.168.XX.107:443
COMMIT
# Completed on Sun Oct  4 18:26:12 2020
# Generated by iptables-save v1.8.3 on Sun Oct  4 18:26:12 2020
*raw
:PREROUTING ACCEPT [147805:74712250]
:OUTPUT ACCEPT [14675:2243023]
:zone_IoT_helper - [0:0]
:zone_guest_helper - [0:0]
:zone_lan_helper - [0:0]
[52345:7497455] -A PREROUTING -i br-lan -m comment --comment "!fw3: lan CT helper assignment" -j zone_lan_helper
[26327:5174684] -A PREROUTING -i wlan0-1 -m comment --comment "!fw3: IoT CT helper assignment" -j zone_IoT_helper
[0:0] -A zone_IoT_helper -p udp -m comment --comment "!fw3: Amanda backup and archiving proto" -m udp --dport 10080 -j CT --helper amanda
[0:0] -A zone_IoT_helper -p udp -m comment --comment "!fw3: RAS proto tracking" -m udp --dport 1719 -j CT --helper RAS
[0:0] -A zone_IoT_helper -p tcp -m comment --comment "!fw3: Q.931 proto tracking" -m tcp --dport 1720 -j CT --helper Q.931
[0:0] -A zone_IoT_helper -p tcp -m comment --comment "!fw3: IRC DCC connection tracking" -m tcp --dport 6667 -j CT --helper irc
[0:0] -A zone_IoT_helper -p tcp -m comment --comment "!fw3: PPTP VPN connection tracking" -m tcp --dport 1723 -j CT --helper pptp
[0:0] -A zone_IoT_helper -p tcp -m comment --comment "!fw3: SIP VoIP connection tracking" -m tcp --dport 5060 -j CT --helper sip
[0:0] -A zone_IoT_helper -p udp -m comment --comment "!fw3: SIP VoIP connection tracking" -m udp --dport 5060 -j CT --helper sip
[0:0] -A zone_IoT_helper -p udp -m comment --comment "!fw3: SNMP monitoring connection tracking" -m udp --dport 161 -j CT --helper snmp
[0:0] -A zone_IoT_helper -p udp -m comment --comment "!fw3: TFTP connection tracking" -m udp --dport 69 -j CT --helper tftp
[0:0] -A zone_guest_helper -p udp -m comment --comment "!fw3: Amanda backup and archiving proto" -m udp --dport 10080 -j CT --helper amanda
[0:0] -A zone_guest_helper -p udp -m comment --comment "!fw3: RAS proto tracking" -m udp --dport 1719 -j CT --helper RAS
[0:0] -A zone_guest_helper -p tcp -m comment --comment "!fw3: Q.931 proto tracking" -m tcp --dport 1720 -j CT --helper Q.931
[0:0] -A zone_guest_helper -p tcp -m comment --comment "!fw3: IRC DCC connection tracking" -m tcp --dport 6667 -j CT --helper irc
[0:0] -A zone_guest_helper -p tcp -m comment --comment "!fw3: PPTP VPN connection tracking" -m tcp --dport 1723 -j CT --helper pptp
[0:0] -A zone_guest_helper -p tcp -m comment --comment "!fw3: SIP VoIP connection tracking" -m tcp --dport 5060 -j CT --helper sip
[0:0] -A zone_guest_helper -p udp -m comment --comment "!fw3: SIP VoIP connection tracking" -m udp --dport 5060 -j CT --helper sip
[0:0] -A zone_guest_helper -p udp -m comment --comment "!fw3: SNMP monitoring connection tracking" -m udp --dport 161 -j CT --helper snmp
[0:0] -A zone_guest_helper -p udp -m comment --comment "!fw3: TFTP connection tracking" -m udp --dport 69 -j CT --helper tftp
[0:0] -A zone_lan_helper -p udp -m comment --comment "!fw3: Amanda backup and archiving proto" -m udp --dport 10080 -j CT --helper amanda
[0:0] -A zone_lan_helper -p udp -m comment --comment "!fw3: RAS proto tracking" -m udp --dport 1719 -j CT --helper RAS
[0:0] -A zone_lan_helper -p tcp -m comment --comment "!fw3: Q.931 proto tracking" -m tcp --dport 1720 -j CT --helper Q.931
[0:0] -A zone_lan_helper -p tcp -m comment --comment "!fw3: IRC DCC connection tracking" -m tcp --dport 6667 -j CT --helper irc
[0:0] -A zone_lan_helper -p tcp -m comment --comment "!fw3: PPTP VPN connection tracking" -m tcp --dport 1723 -j CT --helper pptp
[0:0] -A zone_lan_helper -p tcp -m comment --comment "!fw3: SIP VoIP connection tracking" -m tcp --dport 5060 -j CT --helper sip
[0:0] -A zone_lan_helper -p udp -m comment --comment "!fw3: SIP VoIP connection tracking" -m udp --dport 5060 -j CT --helper sip
[0:0] -A zone_lan_helper -p udp -m comment --comment "!fw3: SNMP monitoring connection tracking" -m udp --dport 161 -j CT --helper snmp
[0:0] -A zone_lan_helper -p udp -m comment --comment "!fw3: TFTP connection tracking" -m udp --dport 69 -j CT --helper tftp
COMMIT
# Completed on Sun Oct  4 18:26:12 2020
# Generated by iptables-save v1.8.3 on Sun Oct  4 18:26:12 2020
*mangle
:PREROUTING ACCEPT [147816:74712955]
:INPUT ACCEPT [21687:3840666]
:FORWARD ACCEPT [120766:69711294]
:OUTPUT ACCEPT [14689:2248335]
:POSTROUTING ACCEPT [141218:73076261]
[933:52436] -A FORWARD -o eth0.2 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: Zone wan MTU fixing" -j TCPMSS --clamp-mss-to-pmtu
COMMIT
# Completed on Sun Oct  4 18:26:12 2020
# Generated by iptables-save v1.8.3 on Sun Oct  4 18:26:12 2020
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:forwarding_IoT_rule - [0:0]
:forwarding_guest_rule - [0:0]
:forwarding_lan_rule - [0:0]
:forwarding_rule - [0:0]
:forwarding_wan_rule - [0:0]
:input_IoT_rule - [0:0]
:input_guest_rule - [0:0]
:input_lan_rule - [0:0]
:input_rule - [0:0]
:input_wan_rule - [0:0]
:output_IoT_rule - [0:0]
:output_guest_rule - [0:0]
:output_lan_rule - [0:0]
:output_rule - [0:0]
:output_wan_rule - [0:0]
:reject - [0:0]
:syn_flood - [0:0]
:zone_IoT_dest_ACCEPT - [0:0]
:zone_IoT_dest_REJECT - [0:0]
:zone_IoT_forward - [0:0]
:zone_IoT_input - [0:0]
:zone_IoT_output - [0:0]
:zone_IoT_src_REJECT - [0:0]
:zone_guest_dest_ACCEPT - [0:0]
:zone_guest_dest_REJECT - [0:0]
:zone_guest_forward - [0:0]
:zone_guest_input - [0:0]
:zone_guest_output - [0:0]
:zone_guest_src_REJECT - [0:0]
:zone_lan_dest_ACCEPT - [0:0]
:zone_lan_forward - [0:0]
:zone_lan_input - [0:0]
:zone_lan_output - [0:0]
:zone_lan_src_ACCEPT - [0:0]
:zone_wan_dest_ACCEPT - [0:0]
:zone_wan_dest_REJECT - [0:0]
:zone_wan_forward - [0:0]
:zone_wan_input - [0:0]
:zone_wan_output - [0:0]
:zone_wan_src_REJECT - [0:0]
[94:8584] -A INPUT -i lo -m comment --comment "!fw3" -j ACCEPT
[21598:3832282] -A INPUT -m comment --comment "!fw3: Custom input rule chain" -j input_rule
[3991:701327] -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "!fw3" -j ACCEPT
[326:14708] -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m comment --comment "!fw3" -j syn_flood
[12805:2799360] -A INPUT -d 224.0.0.251/32 -p udp -m udp --sport 5353 --dport 5353 -m comment --comment "!fw3: Allow mDNS" -j ACCEPT
[3857:251440] -A INPUT -i br-lan -m comment --comment "!fw3" -j zone_lan_input
[532:29606] -A INPUT -i eth0.2 -m comment --comment "!fw3" -j zone_wan_input
[413:50549] -A INPUT -i wlan0-1 -m comment --comment "!fw3" -j zone_IoT_input
[120770:69711786] -A FORWARD -m comment --comment "!fw3: Custom forwarding rule chain" -j forwarding_rule
[117690:69364927] -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "!fw3" -j ACCEPT
[2216:277784] -A FORWARD -i br-lan -m comment --comment "!fw3" -j zone_lan_forward
[69:4060] -A FORWARD -i eth0.2 -m comment --comment "!fw3" -j zone_wan_forward
[795:65015] -A FORWARD -i wlan0-1 -m comment --comment "!fw3" -j zone_IoT_forward
[0:0] -A FORWARD -m comment --comment "!fw3" -j reject
[94:8584] -A OUTPUT -o lo -m comment --comment "!fw3" -j ACCEPT
[14605:2241191] -A OUTPUT -m comment --comment "!fw3: Custom output rule chain" -j output_rule
[6837:975690] -A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "!fw3" -j ACCEPT
[2975:825165] -A OUTPUT -o br-lan -m comment --comment "!fw3" -j zone_lan_output
[1889:137825] -A OUTPUT -o eth0.2 -m comment --comment "!fw3" -j zone_wan_output
[2904:302511] -A OUTPUT -o wlan0-1 -m comment --comment "!fw3" -j zone_IoT_output
[310:13816] -A reject -p tcp -m comment --comment "!fw3" -j REJECT --reject-with tcp-reset
[389:32150] -A reject -m comment --comment "!fw3" -j REJECT --reject-with icmp-port-unreachable
[326:14708] -A syn_flood -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m limit --limit 25/sec --limit-burst 50 -m comment --comment "!fw3" -j RETURN
[0:0] -A syn_flood -m comment --comment "!fw3" -j DROP
[3083:321451] -A zone_IoT_dest_ACCEPT -o wlan0-1 -m comment --comment "!fw3" -j ACCEPT
[0:0] -A zone_IoT_dest_REJECT -o wlan0-1 -m comment --comment "!fw3" -j reject
[795:65015] -A zone_IoT_forward -m comment --comment "!fw3: Custom IoT forwarding rule chain" -j forwarding_IoT_rule
[1:44] -A zone_IoT_forward -d 192.168.XX.107/32 -p tcp -m comment --comment "!fw3: Allow HOME ASSISTANT from IoT VLAN" -j zone_lan_dest_ACCEPT
[4:2044] -A zone_IoT_forward -d 192.168.XX.107/32 -p udp -m comment --comment "!fw3: Allow HOME ASSISTANT from IoT VLAN" -j zone_lan_dest_ACCEPT
[790:62927] -A zone_IoT_forward -m comment --comment "!fw3: Zone IoT to wan forwarding policy" -j zone_wan_dest_ACCEPT
[0:0] -A zone_IoT_forward -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port forwards" -j ACCEPT
[0:0] -A zone_IoT_forward -m comment --comment "!fw3" -j zone_IoT_dest_REJECT
[413:50549] -A zone_IoT_input -m comment --comment "!fw3: Custom IoT input rule chain" -j input_IoT_rule
[1:40] -A zone_IoT_input -p tcp -m tcp --dport 53 -m comment --comment "!fw3: IoT DNS" -j ACCEPT
[118:7937] -A zone_IoT_input -p udp -m udp --dport 53 -m comment --comment "!fw3: IoT DNS" -j ACCEPT
[73:24268] -A zone_IoT_input -p udp -m udp --sport 67:68 --dport 67:68 -m comment --comment "!fw3: IoT DHCP" -j ACCEPT
[0:0] -A zone_IoT_input -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port redirections" -j ACCEPT
[221:18304] -A zone_IoT_input -m comment --comment "!fw3" -j zone_IoT_src_REJECT
[2904:302511] -A zone_IoT_output -m comment --comment "!fw3: Custom IoT output rule chain" -j output_IoT_rule
[2904:302511] -A zone_IoT_output -m comment --comment "!fw3" -j zone_IoT_dest_ACCEPT
[221:18304] -A zone_IoT_src_REJECT -i wlan0-1 -m comment --comment "!fw3" -j reject
[0:0] -A zone_guest_forward -m comment --comment "!fw3: Custom guest forwarding rule chain" -j forwarding_guest_rule
[0:0] -A zone_guest_forward -m comment --comment "!fw3: Zone guest to wan forwarding policy" -j zone_wan_dest_ACCEPT
[0:0] -A zone_guest_forward -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port forwards" -j ACCEPT
[0:0] -A zone_guest_forward -m comment --comment "!fw3" -j zone_guest_dest_REJECT
[0:0] -A zone_guest_input -m comment --comment "!fw3: Custom guest input rule chain" -j input_guest_rule
[0:0] -A zone_guest_input -p tcp -m tcp --dport 53 -m comment --comment "!fw3: Guest DNS" -j ACCEPT
[0:0] -A zone_guest_input -p udp -m udp --dport 53 -m comment --comment "!fw3: Guest DNS" -j ACCEPT
[0:0] -A zone_guest_input -p udp -m udp --sport 67:68 --dport 67:68 -m comment --comment "!fw3: Guest DHCP" -j ACCEPT
[0:0] -A zone_guest_input -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port redirections" -j ACCEPT
[0:0] -A zone_guest_input -m comment --comment "!fw3" -j zone_guest_src_REJECT
[0:0] -A zone_guest_output -m comment --comment "!fw3: Custom guest output rule chain" -j output_guest_rule
[0:0] -A zone_guest_output -m comment --comment "!fw3" -j zone_guest_dest_ACCEPT
[2980:827253] -A zone_lan_dest_ACCEPT -o br-lan -m comment --comment "!fw3" -j ACCEPT
[2216:277784] -A zone_lan_forward -m comment --comment "!fw3: Custom lan forwarding rule chain" -j forwarding_lan_rule
[2216:277784] -A zone_lan_forward -m comment --comment "!fw3: Zone lan to wan forwarding policy" -j zone_wan_dest_ACCEPT
[179:18940] -A zone_lan_forward -m comment --comment "!fw3: Zone lan to IoT forwarding policy" -j zone_IoT_dest_ACCEPT
[0:0] -A zone_lan_forward -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port forwards" -j ACCEPT
[0:0] -A zone_lan_forward -m comment --comment "!fw3" -j zone_lan_dest_ACCEPT
[3857:251440] -A zone_lan_input -m comment --comment "!fw3: Custom lan input rule chain" -j input_lan_rule
[0:0] -A zone_lan_input -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port redirections" -j ACCEPT
[3857:251440] -A zone_lan_input -m comment --comment "!fw3" -j zone_lan_src_ACCEPT
[2975:825165] -A zone_lan_output -m comment --comment "!fw3: Custom lan output rule chain" -j output_lan_rule
[2975:825165] -A zone_lan_output -m comment --comment "!fw3" -j zone_lan_dest_ACCEPT
[3857:251440] -A zone_lan_src_ACCEPT -i br-lan -m conntrack --ctstate NEW,UNTRACKED -m comment --comment "!fw3" -j ACCEPT
[92:3732] -A zone_wan_dest_ACCEPT -o eth0.2 -m conntrack --ctstate INVALID -m comment --comment "!fw3: Prevent NAT leakage" -j DROP
[4624:455864] -A zone_wan_dest_ACCEPT -o eth0.2 -m comment --comment "!fw3" -j ACCEPT
[0:0] -A zone_wan_dest_REJECT -o eth0.2 -m comment --comment "!fw3" -j reject
[69:4060] -A zone_wan_forward -m comment --comment "!fw3: Custom wan forwarding rule chain" -j forwarding_wan_rule
[0:0] -A zone_wan_forward -p esp -m comment --comment "!fw3: Allow-IPSec-ESP" -j zone_lan_dest_ACCEPT
[0:0] -A zone_wan_forward -p udp -m udp --dport 500 -m comment --comment "!fw3: Allow-ISAKMP" -j zone_lan_dest_ACCEPT
[69:4060] -A zone_wan_forward -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port forwards" -j ACCEPT
[0:0] -A zone_wan_forward -m comment --comment "!fw3" -j zone_wan_dest_REJECT
[532:29606] -A zone_wan_input -m comment --comment "!fw3: Custom wan input rule chain" -j input_wan_rule
[0:0] -A zone_wan_input -p udp -m udp --dport 68 -m comment --comment "!fw3: Allow-DHCP-Renew" -j ACCEPT
[0:0] -A zone_wan_input -p icmp -m icmp --icmp-type 8 -m comment --comment "!fw3: Allow-Ping" -j ACCEPT
[54:1944] -A zone_wan_input -p igmp -m comment --comment "!fw3: Allow-IGMP" -j ACCEPT
[0:0] -A zone_wan_input -m conntrack --ctstate DNAT -m comment --comment "!fw3: Accept port redirections" -j ACCEPT
[478:27662] -A zone_wan_input -m comment --comment "!fw3" -j zone_wan_src_REJECT
[1890:137906] -A zone_wan_output -m comment --comment "!fw3: Custom wan output rule chain" -j output_wan_rule
[1890:137906] -A zone_wan_output -m comment --comment "!fw3" -j zone_wan_dest_ACCEPT
[478:27662] -A zone_wan_src_REJECT -i eth0.2 -m comment --comment "!fw3" -j reject
COMMIT
# Completed on Sun Oct  4 18:26:12 2020

ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
6: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    inet 192.168.1.2/24 brd 192.168.1.255 scope global eth0.2
       valid_lft forever preferred_lft forever
8: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    inet 192.168.XX.1/24 brd 192.168.XX.255 scope global br-lan
       valid_lft forever preferred_lft forever
17: wlan0-1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    inet 192.168.ZZ.1/24 brd 192.168.ZZ.255 scope global wlan0-1
       valid_lft forever preferred_lft forever
default via 192.168.1.1 dev eth0.2
192.168.1.0/24 dev eth0.2 scope link  src 192.168.1.2
192.168.XX.0/24 dev br-lan scope link  src 192.168.XX.1
192.168.ZZ.0/24 dev wlan0-1 scope link  src 192.168.ZZ.1
broadcast 127.0.0.0 dev lo table local scope link  src 127.0.0.1
local 127.0.0.0/8 dev lo table local scope host  src 127.0.0.1
local 127.0.0.1 dev lo table local scope host  src 127.0.0.1
broadcast 127.255.255.255 dev lo table local scope link  src 127.0.0.1
broadcast 192.168.1.0 dev eth0.2 table local scope link  src 192.168.1.2
local 192.168.1.2 dev eth0.2 table local scope host  src 192.168.1.2
broadcast 192.168.1.255 dev eth0.2 table local scope link  src 192.168.1.2
broadcast 192.168.XX.0 dev br-lan table local scope link  src 192.168.XX.1
local 192.168.XX.1 dev br-lan table local scope host  src 192.168.XX.1
broadcast 192.168.XX.255 dev br-lan table local scope link  src 192.168.XX.1
broadcast 192.168.ZZ.0 dev wlan0-1 table local scope link  src 192.168.ZZ.1
local 192.168.ZZ.1 dev wlan0-1 table local scope host  src 192.168.ZZ.1
broadcast 192.168.ZZ.255 dev wlan0-1 table local scope link  src 192.168.ZZ.1
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

ls -l /etc/resolv.* /tmp/resolv.; head -n -0 /etc/resolv. /tmp/resolv.*

lrwxrwxrwx    1 root     root            16 Feb 27  2020 /etc/resolv.conf -> /tmp/resolv.conf
-rw-r--r--    1 root     root            32 Oct  4 16:32 /tmp/resolv.conf
-rw-r--r--    1 root     root           108 Oct  3 19:00 /tmp/resolv.conf.auto
==> /etc/resolv.conf <==
search lan
nameserver 127.0.0.1

==> /tmp/resolv.conf <==
search lan
nameserver 127.0.0.1

==> /tmp/resolv.conf.auto <==
# Interface lan
nameserver 8.8.8.8
nameserver 8.8.4.4
# Interface wan
nameserver 8.8.8.8
nameserver 8.8.4.4

Okay first the 192.168 addresses are not public, so you don't have to redact them. Same applies for the ULA IPv6 address.
The thing is that the wan IP of your OpenWrt is 192.168.1.2, not some public. So NAT loopback will not work on OpenWrt, it must be configured on your ISP router.

1 Like

thanks a lot, i will try to act on my isp router

You are my hero!!!

The nat loopback worked fine but my ISP router give priority to its remote management page.
I changed the port to 8080 and now everything works great.

1 Like
Client -> R1 -> R2 (NAT loopback) -> R1 -> Server

This looks like a pointless waste of bandwidth.
Even more reason to utilize DNS hijacking.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.