I’m new to crowdsec and just ran into an issue I am stuck right now. Hope you can help me out.
When using cs-firewall-bouncer in nftables mode it cannot ban any IPs.
When I have a look at the log I see a lot of these lines either for the capi provided IPs and for IPs that should be blocked according to my scenarios as well:
time="26-05-2021 18:39:29" level=error msg="unable to insert decision for '20.43.10.201/32': Receive: netlink receive: no such file or directory"
time="26-05-2021 18:39:29" level=error msg="unable to insert decision for '176.218.42.235/32': Receive: netlink receive: no such file or directory"
time="26-05-2021 18:39:29" level=error msg="unable to insert decision for '62.85.37.244/32': Receive: netlink receive: no such file or directory"
time="26-05-2021 18:39:29" level=error msg="unable to insert decision for '40.84.157.160/32': Receive: netlink receive: no such file or directory"
time="26-05-2021 18:39:29" level=error msg="unable to insert decision for '54.78.26.52/32': Receive: netlink receive: no such file or directory"
First question, is the bouncer installed in the same machine where crowdsec is already installed ?
If yes, could you check if you have a registered bouncer with this command : cscli bouncers list.
Does nftables mode interfere with my own ruleset? It seems that it cannot create any of the crowdsec tables…
the bouncer create it own table when it start correctly.
the connection to LAPI works just fine. In my post I just replaced the API token
Yesterday I did some more research and it seems that cs-firewall-bouncer isn’t creating the “crowdsec” table and corresponding chain within nftables. (I only use IPv4)
When I set the cs-firewall-bouncer loglevel to debug it tells me:
But when I run nft list ruleset no “crowdsec” table shows up (this only shows me my own table).
I found this thread on stackexchange, where someone was facing the exact same error message when the table&chain he tries to insert some rules were missing: https://unix.stackexchange.com/a/537935
Next I tried to create the following structure within my nftables.conf manually, to make sure the table and chain exist:
table ip crowdsec {
chain crowdsec_chain {
type filter hook input priority -1; policy accept;
}
}
I chose priority -1 for it to be evaluated before my own table which has priority 0.
After creating the table manually and verified it’s there via nft list ruleset I restarted cs-firewall-bouncer and all it does, is removing the table according to the shutdown sequence but it never creates a new table…
I really don’t know what I am missing…
edit: Here’s the output I get from cs-firewall-bouncer.log when I restart the service.
time="27-05-2021 18:55:46" level=info msg="removing 'crowdsec' table"
time="27-05-2021 18:55:46" level=fatal msg="shutdown fail: Receive: netlink receive: no such file or directory"
time="27-05-2021 18:55:46" level=info msg="backend type : nftables"
time="27-05-2021 18:55:46" level=info msg="IPV6 is disabled"
time="27-05-2021 18:55:46" level=info msg="nftables initiated"
time="27-05-2021 18:55:46" level=info msg="Processing new and deleted decisions . . ."
time="27-05-2021 18:55:46" level=info msg="deleting '3012' decisions"
time="27-05-2021 18:56:33" level=info msg="adding '820' decisions"
time="27-05-2021 18:56:33" level=error msg="unable to insert decision for '49.88.112.75/32': Receive: netlink receive: no such file or directory"
time="27-05-2021 18:56:33" level=error msg="unable to insert decision for '222.186.30.112/32': Receive: netlink receive: no such file or directory"
time="27-05-2021 18:56:33" level=error msg="unable to insert decision for '222.186.175.23/32': Receive: netlink receive: no such file or directory"
....
time="28-05-2021 02:36:56" level=info msg="adding '1' decisions"
time="28-05-2021 02:36:57" level=error msg="unable to insert decision for '45.146.164.125': Receive: netlink receive: no such file or directory"
In this example you can see the “fatal” error message on shutdown. This is due to the table it expected doesn’t exist…and it cannot delete what doesn’t exist. It also contains one entry where it is trying to ban an IP as part of a decision, so LAPI connection is working.
Sorry for the delay.
Thanks for those informations. Indeed, the crowdsec table is not even created.
Can you paste me the output of nft add table ip crowdsec please to see what happen when creating the table ?
root@host:/etc/crowdsec# nft add table ip crowdsec
root@host:/etc/crowdsec# nft list ruleset
table ip crowdsec {
}
table inet filter {
chain input {
...
}
But even when I add the table this way, cs-firewall-bouncer isn’t able to add the rules. I get the exact same error message.
When I then restart cs-firewall-bouncer service it sucessfully removes the table due to the shutdown sequence, but actually it doesn’t add a new one while initializing.