Today we will take a look at how to open ports in Ubuntu firewall UFW
UFW is short for Ubuntu Uncomplicated Firewall.
Indeed it is right this firewall is really not that complicated.
So I had the task to open a port to my Webmin service located on TCP port 10000
First let us check what is up with our firewall
Give the command : sudo ufw status
Either you will get the response :
Status : inactive
or more likely if you really have the need for opening a port you will receive a list of open ports like this:
To Action From
— —— —-
22 ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
The above shows that currently my machine will allow SSH,HTTP and HTTPS from anyone who would like to connect to these services.
The security freak will frown upon this. Especially that SSH is open for all, but hey this is how the virtual machine was delivered to me.
So in order for me to allow the Webmin service to be accessible, from my IP address I will enter the following command
sudo ufw allow proto tcp from 192.168.0.2 to any port 22 (Remember to replace 192.168.0.2 with your actual IP address)
If you do not care who accesses this port you could go with the command
sudo ufw allow 10000
that’s it and that’s that!
Note that firewalls may seem uncomplicated, but if you do not think carefully about what you are doing you may open allow for your machines to be accessed by people with bad intentions!