Hey everyone!
I (think I) have a simple firewall use case: Block a single IP address (example: A.B.C.D) with nftables (completely).
Background: A.B.C.D somehow spams my server with 5 permanent multicast UDP connections on the 5 IPs 239.192.84.97–239.192.84.101 at port 5004 (which ~2Mb per connection).
(I hope I’ll have contact in time to the owner of A.B.C.D. ATM I only wanna drop the connection …)
Because I have no service on the port 5004 I use tcpdump/iftop/nethogs to view the connections. The following tcpdump is flooding my terminal …
[root@host:~]# tcpdump -Q in -nn
[…]
19:03:30.812825 IP A.B.C.D.5004 > 239.192.84.100.5004: UDP, length 1452
19:03:30.813367 IP A.B.C.D.5004 > 239.192.84.97.5004: UDP, length 1452
19:03:30.814311 IP A.B.C.D.5004 > 239.192.84.101.5004: UDP, length 1452
19:03:30.814359 IP A.B.C.D.5004 > 239.192.84.99.5004: UDP, length 1452
19:03:30.815310 IP A.B.C.D.5004 > 239.192.84.98.5004: UDP, length 1452
19:03:30.817826 IP A.B.C.D.5004 > 239.192.84.100.5004: UDP, length 1452
19:03:30.817875 IP A.B.C.D.5004 > 239.192.84.97.5004: UDP, length 1452
19:03:30.818818 IP A.B.C.D.5004 > 239.192.84.101.5004: UDP, length 1452
19:03:30.820316 IP A.B.C.D.5004 > 239.192.84.99.5004: UDP, length 1452
19:03:30.820360 IP A.B.C.D.5004 > 239.192.84.98.5004: UDP, length 1452
19:03:30.822320 IP A.B.C.D.5004 > 239.192.84.97.5004: UDP, length 1452
19:03:30.822331 IP A.B.C.D.5004 > 239.192.84.100.5004: UDP, length 1452
19:03:30.823858 IP A.B.C.D.5004 > 239.192.84.101.5004: UDP, length 1452
19:03:30.825321 IP A.B.C.D.5004 > 239.192.84.99.5004: UDP, length 1452
19:03:30.825367 IP A.B.C.D.5004 > 239.192.84.98.5004: UDP, length 1452
19:03:30.828363 IP A.B.C.D.5004 > 239.192.84.100.5004: UDP, length 1452
19:03:30.828537 IP A.B.C.D.5004 > 239.192.84.101.5004: UDP, length 1452
19:03:30.828537 IP A.B.C.D.5004 > 239.192.84.97.5004: UDP, length 1452
19:03:30.829872 IP A.B.C.D.5004 > 239.192.84.99.5004: UDP, length 1452
19:03:30.830828 IP A.B.C.D.5004 > 239.192.84.98.5004: UDP, length 1452
[…]
Setup (stripped-down):
networking = {
firewall = {
enable = true;
extraInputRules = "ip saddr A.B.C.D counter drop";
};
nftables.enable = true;
};
This results in the following nftables rules set:
[root@host:~]# nft list ruleset
table inet nixos-fw {
set temp-ports {
[…]
}
chain rpfilter {
[…]
}
chain rpfilter-allow {
}
chain input {
[…]
}
chain input-allow {
[…]
ip saddr A.B.C.D counter packets 0 bytes 0 drop
}
}
And as you can see, no packets get dropped and I don’t no why … ![]()
Has someone any idea?
(I tried the whole day. Starting with iptables and I also tried firewall rules w/ and w/o protocol/port/… #everything)
Thank you in advance and best regards!