CSF Failed to Start After Ubuntu 20.04 Upgrade – How to Fix

csfubuntu-20.04

Today I have upgraded my Ubuntu 18.04.04 VPS server to Ubuntu 20.04. Now CSF not starting and shows the following error and not start the CSF service.

*Error* The path to iptables is either not set or incorrect for IPTABLES [/sbin/ip6tables] in /etc/csf/csf.conf at /usr/local/csf/lib/ConfigServer/URLGet.pm line 26.
Compilation failed in require at /usr/sbin/csf line 21.
BEGIN failed--compilation aborted at /usr/sbin/csf line 21.

When I test iptables it shows the following result.

root@server:~# sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination    

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination    

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination    
root@server:~# ip6tables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

How do I fix this CSF iptable issue?

Best Answer

You need to check where is your iptables and ip6tables.

Run this on terminal:

whereis iptables

and

whereis ip6tables

Mine is:

whereis iptables

iptables: /usr/sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz

and

whereis ip6tables

ip6tables: /usr/sbin/ip6tables /usr/share/man/man8/ip6tables.8.gz

And update the file /etc/csf/csf.conf:

Binary locations

IPTABLES = "/usr/sbin/iptables"

IPTABLES_SAVE = "/usr/sbin/iptables-save"

IPTABLES_RESTORE = "/usr/sbin/iptables-restore"

IP6TABLES = "/usr/sbin/ip6tables"

IP6TABLES_SAVE = "/usr/sbin/ip6tables-save"

IP6TABLES_RESTORE = "/usr/sbin/ip6tables-restore"

And make sure it works for you.