Score:1

Cannot access website in LAN. NAT Hairpinning in nftables

ga flag

I am trying to get NAT hairpinning working on my router. I cannot access my local website host on my LAN (192.168.1.3). I am using nftables with the following config:

enp1s0 = WAN enp2s0 = LAN

#!/sbin/nft -f
flush ruleset
table ip nat {
        chain prerouting {
                type nat hook prerouting priority -100; policy accept;
                iifname "enp1s0" tcp dport { 80, 443 } dnat to 192.168.1.3
                meta nftrace set 1
        }

        chain postrouting {
                type nat hook postrouting priority 100; policy accept;
                ip saddr 192.168.1.0/24 ip daddr 192.168.1.3 tcp dport { http, https } counter snat 192.168.1.1
                oifname "enp1s0" masquerade
                meta nftrace set 1
        }
}

How exactly can I get hairpinning to work? I have seen people use split DNS but I am not too sure how to set that up.

Score:1
eu flag

To do NAT Hairpinning in nftables you can add a DNAT rule which is checking if the destination address of the packages is the external ip of your network. You also need to do masquerading on the internal interface (LAN).

flush ruleset

define wan = enp1s0
define lan = enp2s0

define webserver = 192.168.1.3
define extip = 1.2.3.4

table ip nat {
        chain prerouting {
                type nat hook prerouting priority dstnat; policy accept;
                tcp dport { 80, 443 } ip daddr $extip dnat to $webserver
        }

        chain postrouting {
                type nat hook postrouting priority srcnat; policy accept;
                oif $wan masquerade
                oif $lan masquerade
        }
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.