How to open a certain port in the UFW firewall in Ubuntu?

Open ports with UFW

You open ports with this ufw command:

sudo ufw allow 22

You can also open a certain range of ports with this command:

sudo ufw allow 8000:8080/tcp

In this command, the “/tcp” part is necessary because when opening ports you must always indicate the protocol, if it is an interval.

Disable firewall ports

Now, to disable the open ports with the previous commands you do the following commands.

sudo ufw delete allow 22

Or in the case of intervals:

sudo ufw delete allow 8000:8080/tcp

See also  Sending email in PHP using Gmail's SMTP server
Loading Facebook Comments ...
Loading Disqus Comments ...