.github/workflows | ||
global | ||
nft-blackhole | ||
services | ||
systemd | ||
ulogd2 | ||
zones | ||
.gitignore | ||
conf.def | ||
fw.nft | ||
LICENSE | ||
log.nft | ||
README.md | ||
scanner.def |
nft-simple-fw
nftables framework ruleset comparting traffic into different zones.
Supports private subnets and vpn interfaces and provides a custom template for nft-blackhole.
Uses performant interface group matching for distinguishing interfaces.
zone policies
Packets traverse different zones depending on distinct criteria, mainly the interface group and/or destination address:
- public: Packets coming from public ip ranges, passing through the main interface(s) (group 1 by default).
- private: Packets coming from local networks, passing through the main interface(s) (group 1 by default).
- forward: Packets destined for other machines or subnets not directly configured on the host but expected to be forwarded.
- vpn: Packets passing through VPN interface(s) (group 2 by default).
- output: Packets originating from the host itself.
- default: Packets not matching any of the above interface groupings (group is unset).
Without any configuration, all zones but output and vpn are configured to reject packets by default if not matching some pre-defined criteria. Please see the zone's source comments for details.
caveats
Packets to ungrouped interfaces traverse the default zone and are only subject to mild filtering when originating from inside the local network. Assign an interface group or customize the zone to change this behaviour. Packets to grouped interfaces, excluding IIFGROUP_{ETHERNET,VPN}
(see conf.def), are rejected by default.
Usage
- Customize conf.def and the filter zones in zones to your liking if you don't agree with the sane defaults.
- Assign interface groups via systemd-networkd (see conf.def), create/edit
services/{default,forward,private,public,vpn,output}.zone.d/*.nft
files for the services you wish to use. - Load via
nft -f fw.nft
, or use the supplied systemd service file systemd/nft-fw.service, which expects the files to reside in/etc/nftables
. - If you are using nft-blackhole, symlink nft-blackhole/template.nft to
/usr/share/nft-blackhole/nft-blackhole.template
. - If you want to keep your kernel log clean, an example configuration for ulogd2 is provided with ulogd2.conf. Only
CHAIN_LOG_DISPATCH_{DROP,REJECT}
inside conf.def need to be set accordingly to utilize the NFLOG target.