There was a problem loading the comments.

How to Open a Firewall Port on Ubuntu Linux?

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Managing firewall rules is essential for controlling network traffic and ensuring security on an Ubuntu server. This guide will show you how to open specific ports using ufw (Uncomplicated Firewall), the default firewall management tool in Ubuntu.

 

Step 1: Check If UFW Is Installed and Enabled

Ubuntu comes with ufw preinstalled. To verify if it’s active, run:

sudo ufw status
  • If the firewall is active, it will show a list of rules.

  • If it's inactive, enable it with:

sudo ufw enable

 

Step 2: Allow Incoming Traffic on a Specific Port

To open a specific port, use the following command:

sudo ufw allow <port_number>

 

For example, to allow HTTP traffic on port 80:

sudo ufw allow 80

 

Step 3: Allow Ports with Specific Protocols

You can specify the protocol (TCP or UDP) when opening a port:

sudo ufw allow 443/tcp   # Opens port 443 for HTTPS traffic
sudo ufw allow 53/udp    # Opens port 53 for DNS queries

 

Step 4: Allow a Port for a Specific IP Address

To allow access from a specific IP address (e.g., 192.168.1.100) to a port:

sudo ufw allow from 192.168.1.100 to any port 22

 

Step 5: Allow Port Ranges

To open a range of ports, use:

sudo ufw allow 5000:6000/tcp

 

Step 6: Delete a Firewall Rule

If you need to close an open port, use:

sudo ufw delete allow 80

 

Step 7: Reload and Verify UFW Rules

After making changes, reload UFW to apply them:

sudo ufw reload

 

To list all active rules:

sudo ufw status numbered

 


Share via
Did you find this article useful?  

Related Articles

Tags

© Softsys Hosting