Configure Firewall to Ubuntu FTP Server

Configure Firewall to Ubuntu FTP Server

If you haven’t already done so, it is recommended that you enable the ufw firewall for Ubuntu 18.04 / 19.10. Before enabling ufw firewall, make sure you add a rule for SSH, otherwise you may get locked out of your server if you’re connected remotely. If you don’t want to set up a firewall, skip to Step 3.

sudo ufw allow OpenSSH

Let’s open ports 20 and 21 for FTP, and ports 40000-50000 for passive FTP. We’ll also open port 990 for TLS, which we will set up later.

sudo ufw allow 20/tcp

sudo ufw allow 21/tcp

sudo ufw allow 40000:50000/tcp
sudo ufw allow 990/tcp

Now, enable the firewall if it isn’t already. Press y and ENTER if warned about disrupting the SSH connection.

sudo ufw enable

To check the status of the firewall, run:

sudo ufw status

If the firewall is running, you should see Status: active and the firewall rules we just added.

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
3306                       ALLOW       Anywhere
20/tcp                     ALLOW       Anywhere
21/tcp                     ALLOW       Anywhere
40000:50000/tcp            ALLOW       Anywhere
990/tcp                    ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)
3306 (v6)                  ALLOW       Anywhere (v6)
20/tcp (v6)                ALLOW       Anywhere (v6)
21/tcp (v6)                ALLOW       Anywhere (v6)
40000:50000/tcp (v6)       ALLOW       Anywhere (v6)
990/tcp (v6)               ALLOW       Anywhere (v6)

Leave a Reply

Your email address will not be published. Required fields are marked *