Set up a Firewall (UFW)

What is UFW

UFW (Uncomplifed FireWall) is a firewall software that is default firewall on Ubuntu Linux. Here I show the basic usage of UFW.

Install UFW

To install UFW, type following.

$ sudo apt install ufw

Enable UFW

You should enable firewall to block dangerous access from outside. To enable UFW, type following.

$ sudo systemctl enable ufw

Check the status of the fiewall

$ sudo ufw status numbered

Allow a service

If you want to allow a service, you can add a service like following. For example, to allow SSH service, you can add a rule by following.

$ ssh ufw allow ssh

Allow a specific port

You can allow a specific port. For example you can allow 2100 tcp port by following.

$ sudo ufw allow 2100/tpc

Allow specific port range

You can also allow specific port range. For example to allow from 9800 to 9900 tcp ports, type following.

$ sudo ufw allow 9800:9900/tcp

Activate the firewall

To activate UFW, type following.

$ sudo ufw enable

Delete a rule from the allowed list

To delete a rule from the allowd list, first you should specify the number of the rule that you want to delete.

$ sudo ufw status numbered

Now you can delete a rule from the allowed list. If you want to delete the rule numbered 1, type following.

$ sudo ufw delete 1

Conclusion

UFW is a firewall that is very easy to use and have enough functions. I recommend you strongly to use a firewall software for security. UFW is a nice choice for not only an entry user but also a betteran user that should be installed as a firewall software.

Last Updated on September 26, 2024 by Kenn


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *