If you’re running a server with Ubuntu or Debian, you’ll need to open specific ports to let traffic through to your services. SSH, HTTP, custom applications. They all need their port opened in the firewall.
UFW (Uncomplicated Firewall) makes this straightforward. It’s simpler than working directly with iptables.
First, check if UFW is already installed:
sudo ufw status
If it returns a status, you’re good to go. If not, install it now. We’ll update the system at the same time:
sudo apt update && sudo apt upgrade && sudo apt install ufw
Before enabling UFW, allow SSH access. Otherwise you’ll lock yourself out:
sudo ufw allow ssh
Now enable the firewall:
sudo ufw enable
This starts UFW with its default rules. SSH access is already permitted.
Open your specific port with the allow command:
sudo ufw allow 2087
This allows traffic on port 2087 for both TCP and UDP. Want to specify the protocol? Add /tcp or /udp:
sudo ufw allow 2087/tcp
Check the rule’s been added:
sudo ufw status
Need to remove a rule later? Use the delete command:
sudo ufw delete allow 2087
Get scalable resources with our VPS hosting with root access and optional software.
Get VPS HostingPerfect for websites and small businesses unlimited bandwidth with cPanel hosting.
Get cPanel Hosting