In this tutorial:
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:
[email protected] [~]# 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:
[email protected] [~]# 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:
[email protected] [~]# 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:
[email protected] [~]# 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:
[email protected] [~]# 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:
[email protected] [~]# 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:
[email protected] [~]# 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:
roo[email protected] [~]# 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:
[email protected] [~]# csf -t
Remove all temporary IP blocks:
csf -tf
Below is an example of the command you can run, highlighted in red:
[email protected] [~]# 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:
[email protected] [~]# 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!
Comments
It looks like this article doesn't have any comments yet - you can be the first. If you have any comments or questions, start the conversation!