Basic CSF Commands

In this Dedicated Hosting tutorial we will cover basic CSF commands. The basic commands include Restarting Services, Allowing IP’s, Blocking IP’s, and Unblocking IP’s, among others. After explaining what the command does, we will show you an example of the CSF Command.

Service Control Commands

Service CSF commands:

Here is a breakdown of the the csf service commands:

service csf [start|stop|restart]

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# service csf restart

IPtables Commands:

The iptables may also need to be restarted for ‘hung’ rules. If you ever need to restart iptables, make sure you restart CSF afterwards to apply the firewall rules. Below is a breakdown of iptables commands:

iptables {start|stop|restart|condrestart|status|panic|save}

Below is an example of a command you can run, highlighted in red:

root@ded999 [~]# iptables restart

CSF Commands

Block an IP address (permanently):

csf -d $ip

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -d 123.456.789

Block an IP address (temporarily):

csf -td $ip $duration (duration is how long to block for (default:seconds, can use one suffix of h/m/d)

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -td 123.456.789 3600

Allow an IP Address:

csf -a $ip

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -a 123.456.789

Temporarily Allow an IP Address:

csf -ta $ip $duration (duration is how long to block for (default:seconds, can use one suffix of h/m/d)

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -ta 123.456.789 3600

Unblock an IP (permanent block):

csf -dr $ip

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -dr 123.456.789 3600

Unblock an IP (temporary block):

csf -tr $ip

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -tr 123.456.789 3600

List temporary blocked IPs and block durations:

csf -t

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -t

Remove all temporary IP blocks:

csf -tf

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -tf

Log all SYN packets from an IP:

csf -w $ip

Below is an example of the command you can run, highlighted in red:

root@ded999 [~]# csf -w 123.456.789

Congratulations, now you are familiar with the basic CSF commands for Restarting Services, Allowing IP’s, Blocking IP’s, and Unblocking IP’s, among others!

Was this article helpful? Let us know!