You are not logged in.

#1 2018-09-03 10:49:12

DBAGibbz
Member
Registered: 2018-04-04
Posts: 14

[solved] nftables NAT setup help

Im setting up a linux box as a router/gateway. Very simple to start with while I am testing. So I have a nftable NAT I am using to route to various other internet devices on the network (load balancing). But for now pointing all to the same device for testing.

My linux server is 192.168.1.2 which is also running a dnsmasq for DHCP and DNS. Internet is on 192.168.1.3 for now, so I want to NAT data to that address.

The problem I have is that when I apply the nftable rules bellow, the DNS stops working (and seemingly services such as mpd and kde connect). On a client machine I can ping internet IP’s and the linux server, but DNS is failing. Any ideas on how to fix this issue?

# setup table
sudo nft flush ruleset
sudo nft add table NAT
sudo nft add chain NAT prerouting { type nat hook prerouting priority 0 ; }
sudo nft add chain NAT postrouting { type nat hook postrouting priority 100 ; }

# testing either of the following lines for my NAT rule
sudo nft add rule NAT postrouting ip saddr 192.168.1.0/24 oif br0 snat 192.168.1.3
# or this, but not both
sudo nft add rule NAT prerouting dnat to numgen inc mod 2 map {0 : 192.168.1.3, 1 : 192.168.1.3 }

Last edited by DBAGibbz (2018-09-03 12:31:30)

Offline

#2 2018-09-03 12:31:02

DBAGibbz
Member
Registered: 2018-04-04
Posts: 14

Re: [solved] nftables NAT setup help

Solution was the following:

    NAT table
    sudo nft flush ruleset
    sudo nft add table NAT
    sudo nft add chain NAT prerouting { type nat hook prerouting priority 0 \; }
    sudo nft add chain NAT postrouting { type nat hook postrouting priority 100 \; }

    sudo nft add rule NAT postrouting ip saddr 192.168.1.0/24 masquerade

Offline

Board footer

Powered by FluxBB