Skip to content
Sign In Create account

Running a server

Protect a server with a firewall (CSF)

Install ConfigServer Firewall, and the settings that matter on the first day.

1 min read Updated

A server you rent is yours to secure. ConfigServer Firewall (CSF) is the usual first step on a Linux server: it controls which ports are reachable and, through its login-failure daemon, blocks addresses that keep guessing passwords.

These steps assume you are connected over SSH as root.

Install it

bash
cd /usr/local/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf

Then run the installer that matches the server:

bash
./install.cpanel.sh      # a server running cPanel/WHM
./install.directadmin.sh # a server running DirectAdmin
./install.generic.sh     # a server with no hosting panel

CSF installs into /etc/csf and picks up the ports currently in use.

Before you walk away

  1. Open /etc/csf/csf.conf and check that your SSH port is in TCP_IN. Locking yourself out is the classic first mistake.
  2. Restart the firewall so the rules apply:

    ``bash csf -r ``

  3. When you are sure you can still connect, take it out of testing mode: set TESTING = "0" in /etc/csf/csf.conf and restart again. While TESTING is 1, the rules are flushed every few minutes and protect nothing.

Important

Keep the server's management panel to hand while you work — it is how you get back in if a rule shuts you out. See Access your VPS or dedicated server.

Useful commands

bash
csf -a 203.0.113.10   # allow an address
csf -d 203.0.113.10   # block an address
csf -g 203.0.113.10   # see why an address is blocked
csf -tf               # clear all temporary blocks

Still stuck?

Open a ticket from your control panel and say which step you reached. A screenshot of what you see is the fastest way to show us.

Still stuck

Nothing here fits? Write to us.

Tell us what you are trying to do rather than what went wrong, and we will tell you whether it is something we can fix from here.

  • Answered by a person

    There is no ticket robot in front of us. What you write is what somebody reads.

  • Say what you are trying to do

    The fastest answers come from the message that explains the goal, not only the error.

  • Your services are already in front of us

    Sign in first and we can see the account the question is about without asking you to describe it.