When I first switched from iptables to nftables in early 2026, I expected a cleaner rule set and better performance. Instead, my OpenVPN client on a Debian 12 host stopped receiving any packets after the firewall rebooted. The packets were being dropped silently—no log entry, no obvious error. The culprit turned out to be a subtle default in nftables that treats unknown protocols as “reject” rather than “accept”. Below is a step‑by‑step diagnosis and a set of practical fixes that keep your VPN secure without opening a hole in the firewall.
1. The default “reject” behaviour
In nftables every chain has a policy that applies when no rule matches.
The default policy is accept for the filter table, but the nat and mangle tables default to reject. When you create a new table without specifying a policy, nftables falls back to the kernel’s default, which is reject for packets that don’t match any rule. This is a safety feature that protects against accidental exposure of services.
When I added a minimal filter table for the VPN:
nft add table inet vpn
nft add chain inet vpn input { type filter hook input priority 0 \; policy accept \; }
I omitted the policy accept line. The kernel applied its default reject policy, so every packet that didn’t hit an explicit rule was dropped. Since OpenVPN uses UDP on port 1194 and a few control packets on TCP 443 for fallback, those packets never matched any rule and were silently rejected.
2. Detecting the silent drop
The first clue was the absence of logs. By default, nftables does not log rejected packets unless you explicitly add a log rule. To see what was happening, I enabled a temporary log rule:
nft add rule inet vpn input ip protocol udp log prefix "nft-drop: " counter
After restarting OpenVPN, the kernel produced a flood of nft-drop log entries for UDP 1194. The log showed the packet was being dropped by the chain’s policy, not by an explicit rule.
3. Fixing the policy
The simplest fix is to set an explicit accept policy on the chain that handles VPN traffic:
nft add chain inet vpn input { type filter hook input priority 0 \; policy accept \; }
If you already have a chain, just modify it:
nft change chain inet vpn input policy accept
This tells nftables to allow any packet that doesn’t match a rule, which is what you want for a VPN that should accept all inbound traffic from the VPN client.
4. Adding explicit allow rules
While a permissive policy is fine for a dedicated VPN interface, it’s safer to be explicit about which traffic you allow. A common pattern is:
nft add rule inet vpn input iifname "tun0" ct state established,related accept
nft add rule inet vpn input iifname "tun0" ip protocol udp udp dport 1194 accept
nft add rule inet vpn input iifname "tun0" ip protocol tcp tcp dport 443 accept
These rules:
- Accept established/related connections (the return traffic from the VPN server).
- Allow the OpenVPN control channel on UDP 1194.
- Allow fallback TCP 443 if you use
proto udpwithremote-cert-tls serverandtls-auth.
If you use a different interface name or port, adjust accordingly.
5. Avoiding the “unknown protocol” trap
Some VPN clients use GRE or ESP (IP protocol 47/50) for encapsulation. If you forget to allow those, the packets will be dropped. Add:
nft add rule inet vpn input iifname "tun0" ip protocol 47 accept
nft add rule inet vpn input iifname "tun0" ip protocol 50 accept
If you’re running WireGuard, you’ll need to allow UDP 51820 and the kernel’s ip6tables rules for IPv6.
6. Persisting the rules
Unlike iptables, nftables does not automatically reload rules on reboot unless you use a systemd unit or a distribution‑specific service. On Debian, the nftables package ships with /etc/nftables.conf. Add your rules there:
#!/usr/sbin/nft -f
table inet vpn {
chain input {
type filter hook input priority 0; policy accept;
iifname "tun0" ct state established,related accept
iifname "tun0" ip protocol udp udp dport 1194 accept
iifname "tun0" ip protocol tcp tcp dport 443 accept
iifname "tun0" ip protocol 47 accept
iifname "tun0" ip protocol 50 accept
}
}
Then enable the service:
systemctl enable nftables
systemctl restart nftables
7. Trade‑offs and hardening tips
| Approach | Pros | Cons |
|---|---|---|
| Accept policy + explicit rules | Clear intent, minimal rule set | Still accepts any packet that matches the interface |
| Reject policy + explicit allow | Strict by default, easier to audit | Requires more rules, risk of missing a needed rule |
| Logging every drop | Immediate visibility | Log spam, potential DoS if misconfigured |
For most VPN deployments, the “accept policy + explicit allow” pattern is a good balance. It keeps the firewall simple while still allowing you to audit which ports are exposed.
If you’re hardening a server that also serves web services, consider placing the VPN chain before the public chains, so that VPN traffic bypasses the stricter rules applied to the external interface.
8. Common pitfalls
| Symptom | Likely cause | Fix |
|---|---|---|
| VPN client shows “Connection refused” | Policy reject on chain | Set policy accept or add explicit allow |
| No logs for dropped packets | No log rule | Add a temporary log rule to diagnose |
VPN works after nft flush chain | Cached rules missing | Ensure rules are persisted in /etc/nftables.conf |
| VPN drops after reboot | Service not enabled | systemctl enable nftables |
9. Quick checklist
- Verify interface name (
ip a). - Set chain policy to accept or reject as desired.
- Add explicit allow rules for VPN protocols and ports.
- Persist the configuration in
/etc/nftables.conf. - Enable the nftables service.
- Test with
nft list rulesetandtcpdump -i tun0.
10. Final thoughts
The drop I experienced was a classic case of a missing policy in nftables. The kernel’s default “reject” is a good safety net, but it can bite when you’re migrating from iptables. By explicitly setting the policy and adding a handful of allow rules, you can keep your VPN traffic flowing while maintaining a clean, auditable firewall.
For more details on nftables syntax and best practices, the official documentation is a great reference: https://docs.kernel.org/netfilter/nftables/index.html.
See also
- Application-Level Firewalls
- Diagnosing a Persistent 0.0.0.0 Route That Blocks SSH via nftables
- Fixing a Midnight DNS Loop: When nftables Drops Queries on VPN Bridge
- Fixing “Permission denied (publickey)” after moving /etc/ssh/sshd_config
- Stopping /var/log from Dooming Your Server with a Simple tmpfs Trick
- Debugging flaky DNS on a Raspberry Pi bridge setup with nftables rules