Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Ufw firewall configuration under Ubuntu

Shulou Source: shulou.com Published: 2022-06-01 04:00:30 10月06日 Update

Ufw is a simple firewall configuration tool under Ubuntu, and the bottom layer still calls iptables to deal with it. Although the function is simple, it is more practical for desktop applications. It has all the basic common functions and is easy to use.

1. Installation

Sudo apt-get install ufw

two。 Enable

Sudo ufw enable

Sudo ufw default deny

After running the above two commands, the firewall is turned on and automatically turned on when the system starts.

Turn off all external access to the local machine, but the external access to the local machine is normal.

3. Enable / disable

Sudo ufw allow | deny [service]

Open or close a port, for example:

Sudo ufw allow smtp allows all external IP access to the native 25/tcp (smtp) port

Sudo ufw allow 22/tcp allows all external IP access to the native 22/tcp (ssh) port

Sudo ufw allow 53 allows external access to port 53 (tcp/udp)

Sudo ufw allow from 192.168.1.100 allows this IP to access all native ports

Sudo ufw allow proto udp 192.168.0.1 port 53 to 192.168.0.2 port 53

Sudo ufw deny smtp prohibits external access to smtp services

Sudo ufw delete allow smtp deletes one of the rules established above

4. View firewall status

Sudo ufw status

For ordinary users, you only need to set the following settings:

Sudo apt-get install ufw

Sudo ufw enable

Sudo ufw default deny

The above three commands are secure enough. If you need to open some services, use sudo ufw allow to open them.

Tags: Port native firewall fire protection function command service configuration utility security just need tools common underlying desktop status user simple system rule Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Microsoft OPPO Reno MariaDB