How To Ubuntu Linux Firewall Open Port Command

How To Ubuntu Linux Firewall Open Port Command

To open a port in Ubuntu's firewall, you can use the ufw command. ufw stands for "Uncomplicated Firewall," and it is a frontend for managing the iptables firewall on Ubuntu.

Here are the steps to open a port using ufw:

  1. First, make sure that ufw is installed on your system. You can check if it is installed by running the following command:
sudo ufw status
Sour‮ww:ec‬w.lautturi.com
  1. If ufw is not installed, you can install it by running the following command:
sudo apt-get install ufw
  1. Once ufw is installed, you can enable it by running the following command:
sudo ufw enable
  1. To open a port, use the ufw allow command followed by the port number and the protocol (TCP or UDP). For example, to open port 80 for TCP connections, you can run the following command:
sudo ufw allow 80/tcp
  1. To open a range of ports, you can specify the range using the : symbol. For example, to open ports 8000-8007 for TCP connections, you can run the following command:
sudo ufw allow 8000:8007/tcp
  1. To open a port for both TCP and UDP connections, you can specify both protocols separated by a comma. For example, to open port 53 for both TCP and UDP connections, you can run the following command:
sudo ufw allow 53/tcp,53/udp
  1. To verify that the port is open, you can run the ufw status command. This will show you a list of the open ports and the allowed connections.
sudo ufw status
Created Time:2017-10-29 22:08:33  Author:lautturi