nft
is causing me endless headaches, no matter how I tweak the policy, I still cannot get it to function.
The concept I have in mind :
- One "base" chain where common rules live (e.g. allow
ssh
etc.) - One or more application specific where daemon specific rules live (e.g. http server chain)
I have tried many different permutations of rules, but I can never get both "base" + daemon traffic flowing, I always end up blocking one or the other ! ;-(
Here is my current (simplified) config (as presently constituted it allows ssh
but fails to allow http
)
/etc/nftables.conf:
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
counter input_ssh {}
set my_admin_ipv4 {
type ipv4_addr
flags interval
counter
elements = {
10.0.0.0/8,
172.16.0.0/12,
192.168.0.0/16
}
}
chain input {
type filter hook input priority filter;
iifname lo accept comment "Allow loopback traffic";
ct state established,related accept comment "Allow established/related connections";
ct state invalid drop comment "Deny invalid connections";
# SSH
tcp dport ssh ip saddr @my_admin_ipv4 counter name input_ssh accept comment "Allow IPv4 SSH from Admin";
policy drop;
}
chain forward {
type filter hook forward priority 0;
policy drop;
}
chain output {
type filter hook output priority 0;
}
include "/etc/nft/*.conf"
}
/etc/nft/http.conf:
counter input_http {}
chain http {
type filter hook input priority filter - 1;
# HTTP #
tcp dport {80,443} counter name input_nginx accept comment "Allow HTTP";
policy accept;
}