I'm running a Debian Linux server.
I need to open some firewall ports; usually this is easy as pie with iptables, but this server is running nftables.
When I open the conf file, it's not showing rules:
cx:/etc# cat nftables.conf
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
}
chain forward {
type filter hook forward priority 0;
}
chain output {
type filter hook output priority 0;
But if I list the rules, I can see them:
:/etc# nft list ruleset
table inet filter {
chain input {
jump phonesystem
}
chain phonesystem {
ip daddr 224.0.1.75 counter packets 0 bytes 0 accept
tcp dport { http, https, sip, sip-tls, 5062, 5090 } ct state new counter packets 0 bytes 0 accept
udp dport { sip, 5090, 7000-10999 } counter packets 0 bytes 0 accept
}
}
table ip filter {
chain INPUT {
meta l4proto tcp tcp dport 22 counter packets 0 bytes 0 accept
jump phonesystem
}
chain phonesystem {
ip daddr 224.0.1.75 counter packets 0 bytes 0 accept
tcp dport { http, https, sip, sip-tls, 5062, 5090 } ct state new counter packets 0 bytes 0 accept
udp dport { sip, 5090, 7000-10999 } counter packets 0 bytes 0 accept
}
chain FORWARD {
type filter hook forward priority 0; policy accept;
}
chain OUTPUT {
type filter hook output priority 0; policy accept;
meta l4proto tcp tcp dport 22 counter packets 0 bytes 0 accept
}
}
table ip6 filter {
chain INPUT {
jump phonesystem
}
chain phonesystem {
tcp dport { http, https, sip, sip-tls, 5062, 5090 } ct state new counter packets 0 bytes 0 accept
udp dport { sip, 5090, 7000-10999 } counter packets 0 bytes 0 accept
}
chain FORWARD {
type filter hook forward priority 0; policy accept;
}
chain OUTPUT {
type filter hook output priority 0; policy accept;
}
}
table ip security {
chain INPUT {
type filter hook input priority 150; policy accept;
}
chain FORWARD {
type filter hook forward priority 150; policy accept;
}
chain OUTPUT {
type filter hook output priority 150; policy accept;
}
Now I want to open, for example, port 4001.
I have tried numerous commands to the IP Table and the chain phonesystem, but I always get a syntax error. Curious where I am going wrong here!
e.g.
:/etc# nft add rule ip filter input tcp dport 4001 accept
Error: Could not process rule: No such file or directory
add rule ip filter input tcp dport 4001 accept
or
:/etc# nft add rule ip phonesystem tcp dport 4001 counter accept
Error: syntax error, unexpected tcp, expecting string
add rule ip phonesystem tcp dport 4001 counter accept
If I wanted to open a few more ports, how exactly would I add this to the phonesystem chain?