#!/usr/bin/nft -f # IPv4/IPv6 Simple & Safe firewall ruleset. # More examples in /usr/share/nftables/ and /usr/share/doc/nftables/examples/. # some codes from https://wiki.archlinux.org/title/Nftables # needed for reload config using `sudo systemctl restart nftables` or `sudo nft -f /etc/nftables.conf` table inet my_table delete table inet my_table table inet my_table { chain my_input { type filter hook input priority filter policy drop ct state invalid drop comment "early drop of invalid connections" ct state {established, related} accept comment "allow tracked connections" iifname lo accept comment "allow from loopback" ip protocol icmp accept comment "allow icmp" meta l4proto ipv6-icmp accept comment "allow icmp v6" #tcp dport ssh accept comment "allow sshd" #tcp dport searx accept comment "allow searx" tcp dport qrcp accept comment "allow qrcp" udp dport mdns accept comment "allow mdns" pkttype host limit rate 5/second counter reject with icmpx type admin-prohibited counter comment "count any other traffic" } chain my_forward { type filter hook forward priority filter policy drop # Drop everything forwarded to us. We do not forward. That is routers job. } chain my_output { type filter hook output priority filter policy accept # Accept every outbound connection } }