Services running on Ubuntu or Debian need specific ports opened in the firewall before they can receive traffic. SSH connections, web servers and custom applications all require their ports to be accessible.
You will install UFW (Uncomplicated Firewall), configure SSH access to prevent lockouts and open the ports your services need. UFW provides a simpler interface than working directly with iptables.
UFW may already be installed on your system. You will check for an existing installation before attempting to install it.
sudo ufw statussudo apt update && sudo apt upgrade && sudo apt install ufwUFW is now installed and ready to configure. You will enable it and open your required ports in the next section.
You must allow SSH access before enabling UFW. This prevents you from being locked out of your server when the firewall starts blocking traffic.
sudo ufw allow sshsudo ufw enabley and press Enter to confirm. Your SSH rule from the previous step keeps your current connection active.2087 with your port number:sudo ufw allow 2087sudo ufw allow 2087/tcpsudo ufw statusYour port is now open and accepting traffic. Services listening on this port can receive connections from external sources.
You can delete rules when you no longer need a port open. This closes the port and blocks traffic that was previously allowed.
2087 with the port number you want to close:sudo ufw delete allow 2087sudo ufw statusThe port is now closed and will reject incoming connections.
Your Ubuntu or Debian server now has UFW configured with the ports your services need. You installed the firewall, protected SSH access and opened specific ports for incoming traffic. Services listening on these ports can now receive connections.
Review your firewall rules periodically and close ports you no longer use. This reduces your server’s attack surface. Our VPS hosting includes full root access for complete firewall control.
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