Page 1 of 1

Reducing the number of iptables rules

Posted: 18 Mar 2015, 11:24
by owkaye
Lately I have been getting this error every day when my server reboots in the morning:
Error: The VPS iptables rule limit (numiptent) is too low (512/512) - stopping firewall to prevent iptables blocking all connections, at line 583 in /usr/sbin/csf
Most online references suggest that the solution to this problem is to get my VPS host to increase the numiptent value, which they will not do. Instead of switching to a new host that will increase my numiptent value, is it possible to reduce my iptables rules -- for example by combining several rules into one -- so that my rules are less which might stop this error from occuring?

Does csf generate iptables rules every time the server is rebooted? If so, how can I modify the script that generates these rules so that fewer rules are created?

Re: Reducing the number of iptables rules

Posted: 30 May 2015, 14:56
by Texas Trophy
Since a majority of questions go unanswered around here, I am going to help where possible. I am new to CSF but I was encountering the same issue.

Apparently you have raised the DENY_IP_LIMIT.? That is what I did to encounter the error. So I set the limit back to original (200 in my case) and what I did instead was I created a link to my own deny IP list in the "lfd Blocklists" and it seems to be working fine as far as I can tell.

Code: Select all

# My Block List
MYBLOCKLIST|86400|0|http://www.domain.com/deny.txt
I think there is also another alternative that I did not notice until I did the above but it looks like you can basically do the same with LF_GLOBAL and GLOBAL_DENY in the firewall configuration?

Re: Reducing the number of iptables rules

Posted: 30 May 2015, 15:37
by Texas Trophy
Well scratch all of the above. I restarted the firewall once again and then got the error.

Re: Reducing the number of iptables rules

Posted: 03 Jun 2015, 03:54
by tommyk
I would recommend you to use the ipset option. Iptables can't really handle a huge amount of rules, while ipset is easily able to block tens of thousands of IPs without any significant performance reduction.