Steps to set up UFW firewall on Ubuntu

  

For the UFW firewall of Ubuntu system, many people still don't know how to set it up. They only know how to turn it on and off. The following is a brief introduction to Ubuntu's simple way to set up UFW firewall. Friends who don't set up Ubuntu firewall can learn.

Installation

sudo apt-get install ufw

Of course, this is a graphical interface (relatively simple), Synaptic again in search gufw Try ……

How to use

1. Enable

sudo ufw enable

sudo ufw default deny

Function: On The firewall is started with the system and all external access to the machine is turned off (the local access is normal).

2, close

sudo ufw disable

3, check the firewall status

sudo ufw status

4, open /disable the corresponding Port or service example

sudo ufw allow 80 Allow external access to port 80

sudo ufw delete allow 80 Disable external access to port 80

sudo ufw allow from 192.168.1.1 Allow this IP access to all native ports

sudo ufw deny smtp prohibit external access to smtp services

sudo ufw delete allow smtp delete one of the rules established above

ufw deny proto tcp From 10.0.0.0/8 to 192.168.0.1 port To reject all traffic from TCP 10.0.0.0/8 to port 22 address 192.168.0.1

Allow all RFC1918 networks (LAN/WLAN) Access to this host (/8, /16, /12 is a network rating):

sudo ufw allow from 10.0.0.0/8

sudo ufw allow from 172.16.0.0/12< Br>

sudo ufw allow from 192.168.0.0/16

Recommended settings

sudo apt-get Install ufw

sudo ufw enable

sudo ufw default deny

This setting is very safe. If you have special needs, you can use sudo ufw allow to start the service.

The above is the introduction of Ubuntu UFW firewall method. This article only introduces the simple setting of UFW firewall, but it is basically enough for general users.

Copyright © Windows knowledge All Rights Reserved