UFW (Uncomplicated Firewall) is a software that provides a user interface for managing the firewall of a Linux operating system. It is a simple and user-friendly tool that helps protect a computer or network server by blocking unwanted network connections.

 

UFW installation

1. If you have not installed UFW yet we can install it with this command:

sudo apt-get install ufw

2. When the installation is ready you can enable UFW with this command:

sudo ufw enable

Opening a port 

1. You can open a port from the firewall with this command. I'm using port 80 for example.

sudo ufw allow 80

2. You can also assign a specific protocol to a port, for example: "sudo ufw allow 80/tcp".

3. You can check the firewall rules with this command:

sudo ufw status

Closing a port

1. You can deny ports from the firewall with this command. I'm using port 81 for example.

sudo ufw deny 81

Whitelisting IP addresses

You can allow IP addresses from the firewall with this command:

sudo ufw allow from 192.168.1.100

*Remember to change the example address to the one you want to allow.


Denying IP addresses

You can block network traffic from a specific IP address using the following command:

sudo ufw deny from 192.168.1.100

*Remember to change the example address to the one you want to deny.


Enabling and disabling UFW

You can enable the firewall with this command:

sudo ufw enable

You can disable the firewall with this command:

sudo ufw disable

I hope this guide was helpful and you learned the basics about UFW.

Was this answer helpful? 2 Users Found This Useful (5 Votes)