|
@ -30,67 +30,75 @@ in `/etc/nftables.conf`: |
|
|
# flush only my tables |
|
|
# flush only my tables |
|
|
table inet myfilter |
|
|
table inet myfilter |
|
|
delete table inet myfilter |
|
|
delete table inet myfilter |
|
|
table ip mynatv4 |
|
|
table ip mynat |
|
|
delete table ip mynatv4 |
|
|
delete table ip mynat |
|
|
|
|
|
|
|
|
table inet myfilter { |
|
|
table inet myfilter { |
|
|
chain myinput { |
|
|
chain input { |
|
|
# use the "input" hook for this chain |
|
|
|
|
|
# accepts packets by default, because we don't want |
|
|
# accepts packets by default, because we don't want |
|
|
# to have to keep track of all interfaces we don't want |
|
|
# to have to keep track of all interfaces we don't want |
|
|
# firewalled (lan0, wlan0, lxdbr0, veths, etc) |
|
|
# firewalled (lan0, wlan0, bridges, veths, etc) |
|
|
type filter hook input priority 0; policy accept; |
|
|
type filter hook input priority 0; policy accept; |
|
|
|
|
|
|
|
|
# allow established/related connections |
|
|
|
|
|
ct state {established, related} accept |
|
|
|
|
|
|
|
|
|
|
|
# drop invalid connections |
|
|
# drop invalid connections |
|
|
ct state invalid drop |
|
|
ct state invalid drop |
|
|
|
|
|
|
|
|
# packets that are received on a firewalled interface |
|
|
# packets that are received on a firewalled interface |
|
|
# are sent to the firewall chain for evaluation |
|
|
# are sent to the firewall chain for evaluation |
|
|
iifname "wan0" jump myfirewall |
|
|
iifname wan0 jump firewall |
|
|
} |
|
|
} |
|
|
chain myfirewall { # handle firewall |
|
|
chain firewall { |
|
|
|
|
|
# allow established/related connections |
|
|
|
|
|
ct state {established, related} accept |
|
|
|
|
|
|
|
|
# accept incoming HTTP(s) connections |
|
|
# accept incoming HTTP(s) connections |
|
|
tcp dport {http, https} accept |
|
|
tcp dport {80, 443} accept |
|
|
|
|
|
|
|
|
# accept incoming SSH connections |
|
|
# accept incoming SSH connections |
|
|
tcp dport 4322 accept |
|
|
tcp dport 4322 accept |
|
|
|
|
|
|
|
|
|
|
|
# accept incoming SSH connections for gitea |
|
|
|
|
|
tcp dport 4323 accept |
|
|
|
|
|
|
|
|
|
|
|
# accept incoming minecraft MP connections |
|
|
|
|
|
udp dport {19132, 19133} accept |
|
|
|
|
|
tcp dport {19132, 19133} accept |
|
|
|
|
|
|
|
|
|
|
|
# block mDNS broadcasts |
|
|
|
|
|
udp dport 5353 drop |
|
|
|
|
|
|
|
|
# reject everything else |
|
|
# reject everything else |
|
|
reject with icmpx type port-unreachable |
|
|
reject |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
chain myforward { |
|
|
chain forward { |
|
|
# forward everything by default |
|
|
# forward everything by default |
|
|
type filter hook forward priority 0; policy accept; |
|
|
type filter hook forward priority 0; policy accept; |
|
|
|
|
|
|
|
|
# forward incoming on wan0 for established/related connections |
|
|
# drop invalid connections |
|
|
iifname wan0 ct state {established, related} accept |
|
|
ct state invalid drop |
|
|
|
|
|
|
|
|
# drop everything else |
|
|
|
|
|
iifname wan0 drop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# send packets recieved on WAN to firewall chain |
|
|
|
|
|
iifname wan0 jump firewall |
|
|
} |
|
|
} |
|
|
chain myoutput { |
|
|
chain output { |
|
|
# let everything out by default |
|
|
# let everything out by default |
|
|
type filter hook output priority 0; policy accept; |
|
|
type filter hook output priority 0; policy accept; |
|
|
|
|
|
|
|
|
# block outgoing mDNS broadcasts |
|
|
# block outgoing mDNS broadcasts |
|
|
udp dport 5353 drop |
|
|
udp dport 5353 drop |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
table ip mynatv4 { |
|
|
table ip mynat { |
|
|
chain myprerouting { |
|
|
chain prerouting { |
|
|
type nat hook prerouting priority -100; |
|
|
type nat hook prerouting priority -100; |
|
|
|
|
|
|
|
|
# if I wanted to do port forwarding I could do it like this: |
|
|
# if I wanted to do port forwarding I could do it like this: |
|
|
# forward http to 192.168.82.10 |
|
|
# forward http to 192.168.82.10 |
|
|
#tcp dport http dnat to 192.168.82.10 |
|
|
#tcp dport http dnat to 192.168.82.10 |
|
|
} |
|
|
} |
|
|
chain mypostrouting { |
|
|
chain postrouting { |
|
|
type nat hook postrouting priority 100; |
|
|
type nat hook postrouting priority 100; |
|
|
|
|
|
|
|
|
# masquerade outbound packets going to WAN |
|
|
# masquerade outbound packets going to WAN |
|
|