This document defines the default firewall baseline for the hardened Arch Linux server.
nftables is the modern Linux packet filtering framework. It provides a powerful, low-level firewall system for IPv4 and IPv6.
This guide uses nftables directly instead of UFW because the goal is control, clarity, and explicit rules.
Warning
Do not run UFW and custom nftables rules at the same time unless you know exactly how both are interacting. They can conflict because both manage firewall rules.
The firewall is designed around these rules:
- Drop inbound traffic by default
- Accept established and related traffic
- Accept loopback traffic
- Accept ICMP and ICMPv6 for diagnostics
- Accept SSH
- Optionally accept HTTP/HTTPS
- Log blocked packets
- Reject everything else
- Drop forwarding by default
- Allow outbound traffic
Before editing:
sudo cp /etc/nftables.conf /etc/nftables.conf.bakUse the provided config:
sudo cp configs/nftables.conf /etc/nftables.confOr manually edit:
sudo vim /etc/nftables.confRecommended ruleset:
#!/usr/bin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority filter;
policy drop;
ct state invalid drop comment "drop invalid packets"
ct state { established, related } accept comment "allow established connections"
iif lo accept comment "allow loopback"
ip protocol icmp accept comment "allow IPv4 ICMP"
ip6 nexthdr icmpv6 accept comment "allow IPv6 ICMP"
tcp dport 22 ct state new accept comment "allow SSH"
# Optional web server ports
# tcp dport { 80, 443 } ct state new accept comment "allow HTTP/HTTPS"
log prefix "nftables-drop: " flags all counter comment "log blocked inbound traffic"
reject with icmpx type admin-prohibited
}
chain forward {
type filter hook forward priority filter;
policy drop;
}
chain output {
type filter hook output priority filter;
policy accept;
}
}
Test the file:
sudo nft -f /etc/nftables.confList active rules:
sudo nft list rulesetEnable permanently:
sudo systemctl enable nftables
sudo systemctl restart nftablesFollow logs:
sudo journalctl -f | grep nftables-dropShow ruleset:
sudo nft list ruleset| Rule | Purpose |
|---|---|
ct state invalid drop |
Drops malformed or invalid packets |
ct state { established, related } accept |
Allows replies for existing connections |
iif lo accept |
Allows local loopback traffic |
ip protocol icmp accept |
Allows IPv4 diagnostics |
ip6 nexthdr icmpv6 accept |
Allows IPv6 diagnostics |
tcp dport 22 accept |
Allows SSH |
log prefix "nftables-drop" |
Logs packets not explicitly allowed |
reject with icmpx type admin-prohibited |
Rejects remaining inbound traffic |
forward policy drop |
Prevents routing/forwarding by default |
output policy accept |
Allows outbound traffic for updates and services |
The original working notes included an SSH rate-limit rule. Rate limiting can be useful, but placing it incorrectly may not behave as expected if an earlier SSH accept rule already matches.
For this repository, brute-force control is handled primarily by:
- key-only SSH
- disabled root login
- Fail2Ban
- low
MaxAuthTries
A stricter rate-limit rule can be added later as an advanced option.