Veja o que estou usando, supondo que lan0
esteja conectado à sua rede interna e wan0
ao seu ISP.
Não tenho certeza do que você quer dizer com "cliente DHCP na interface upstream", já que isso é feito com um cliente DHCP, não com nftables. A configuração abaixo não restringe o tráfego de saída para que a solicitação DHCP passe.
#!/usr/bin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
# allow established/related connections
ct state {established, related} accept
# early drop of invalid connections
ct state invalid drop
# allow from loopback
iifname lo accept
# Allow from internal network
iifname lan0 accept
# allow icmp
ip protocol icmp accept
# allow ssh
tcp dport 22 accept comment "SSH in"
reject
}
chain forward {
type filter hook forward priority 0;
# Allow outgoing via wan0
oifname wan0 accept
# Allow incoming on wan0 for related & established connections
iifname wan0 ct state related, established accept
# Drop any other incoming traffic on wan0
iifname wan0 drop
}
chain output {
type filter hook output priority 0;
}
}
table ip nat {
chain prerouting {
type nat hook prerouting priority 0;
# Forward traffic from wan0 to a LAN server
iifname wan0 tcp dport 80 dnat 192.168.0.8 comment "Port forwarding to web server"
}
chain postrouting {
type nat hook postrouting priority 0;
# Masquerade outgoing traffic
oifname wan0 masquerade
}
}