When you rent a Linux-based virtual server, the first rule of ensuring security is to restrict unnecessary access from the outside. Developed instead of dealing with complex iptables rules on Ubuntu, UFW (Uncomplicated Firewall) helps you secure your server within minutes.
Enabling UFW and Basic Rules
UFW usually comes installed by default on Ubuntu servers but is not active. Before enabling it, you must allow port 22 (SSH) so that your SSH connection does not drop:
sudo ufw allow ssh
sudo ufw enable
After entering the enable command, the system warns "Command may disrupt existing ssh connections". Confirm by pressing "y".
Opening Ports for Common Services
In order for your website to be accessible from the outside, you need to allow HTTP (80) and HTTPS (443) ports. With UFW, you can do this by name or by numbering:
sudo ufw allow http
sudo ufw allow 443/tcp
If you are using a specific control panel (For example, 8090 for CyberPanel, 8443 for Plesk), do not forget to open these ports to traffic as well:
sudo ufw allow 8090/tcp
Blocking or Allowing a Specific IP
If you want to completely block (Ban) a malicious IP address you are being attacked from your server, you can apply the deny rule:
sudo ufw deny from 192.168.1.100
If you want to open all privileges on the server only to the IP address of your own office or home:
sudo ufw allow from 203.0.113.50
Checking UFW Status
To see a summary of all the rules you have written and to check whether UFW is active, you can use the status command:
sudo ufw status verbose
We would like to remind you that if you want to take a more professional approach to security settings, we can provide high-level protection with corporate network hardware in our VDS server packages that you will rent through İyibirNet.