Ubuntu 20.04 firewall settings simple tutorial (novice)

Ubuntu 20.04 firewall settings simple tutorial (novice)

Preface

In today's increasingly convenient Internet society, various Internet ransomware viruses emerge in an endless stream. Even Google browsers are constantly updating versions to fix vulnerabilities. Many people believe that only Windows systems are prone to viruses, and that Linux systems are not prone to viruses. They often leave their computers running without installing antivirus software or turning on a firewall. In fact, it is possible to get viruses under Linux, but those viruses can hardly run automatically like they do under Windows. The characteristics of Linux determine that in many cases you need to give root permissions to the software to run. This does greatly reduce the chance of the computer getting a virus. But no matter whether your Linux system is Ubuntu or other distributions, even if you don’t install anti-virus software, the firewall must be turned on. Unfortunately, many of us have the firewall turned off on our computers. Today’s blog mainly teaches you how to turn on the firewall of the Ubuntu system to prevent important computer files from being stolen.

1. Installation

Ubuntu 20.04 generally has UFW (Uncomplicated Firewall) installed by default. It is a lightweight tool that is mainly used to monitor input and output traffic. If it is not installed, install it using the following command:

sudo apt install ufw

Normally, after installation, the system should be disabled by default. Enter the sudo ufw status verbose command to see the following interface:


This means the firewall is not enabled. Enable it below.

2. Enable

Enter the following command in the terminal:

sudo ufw enable
sudo ufw default deny

After running the above two commands, the firewall is enabled and automatically enabled when the system starts. Enter sudo ufw status verbose again and you will see the following interface:


The above default configuration means closing all external access to the local machine, but the local machine can access the outside normally. At the same time, I have opened port 3690 to allow external access to the local machine through port 3690. Here, SVN uses port 3690 by default, so I can submit code to the local machine through SVN from the outside.

3. Enable/disable

For general users, you only need to set the following three commands:

sudo apt install ufw
sudo ufw enable
sudo ufw default deny

It is safe enough. If you need to open certain services, use the sudo ufw allow command to enable them. For example:

sudo ufw allow | deny [service]

Open or close a port, for example:

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

sudo ufw allow 3690 allows external access to port 3690 (svn)

sudo ufw allow from 192.168.1.111 allows this IP to access all local ports sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22 allows the specified IP segment to access a specific port sudo ufw delete allow smtp delete a rule created above, for example, to delete the SVN port, you can use sudo ufw delete allow 3690

4. Enable/disable firewall

sudo ufw enable | disable

5. Examples

Here are some examples of ufw command lines:

ufw enable/disable: Enable/disable ufw

ufw status: View the defined ufw rules ufw default allow/deny: External access is allowed/denied by default ufw allow/deny 20: Allow/deny access to port 20, 20 can be followed by /tcp or /udp, indicating TCP or UDP packets.

sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22: Allows TCP packets from 192.168.0.0/24 to access port 22 of the local machine.

ufw delete allow/deny 20: Delete the previously defined "allow/deny access to port 20" rule

This is the end of this article about the simple tutorial on Ubuntu 20.04 firewall settings (for beginners). For more relevant Ubuntu 20.04 firewall settings content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Teach you step by step how to turn on and off the Ubuntu firewall

<<:  What you need to know about msyql transaction isolation

>>:  Understand the principle of page replacement algorithm through code examples

Recommend

Markup Language - Title

Click here to return to the 123WORDPRESS.COM HTML ...

Summary of JS tips for creating or filling arrays of arbitrary length

Table of contents Preface Direct filling method f...

MySQL cleverly uses sum, case and when to optimize statistical queries

I was recently working on a project at the compan...

14 techniques for high-performance websites

Original : http://developer.yahoo.com/performance...

Pure CSS to achieve left and right drag to change the layout size

Utilize the browser's non- overflow:auto elem...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

vue-table implements adding and deleting

This article example shares the specific code for...

mysql8.0.11 winx64 installation and configuration tutorial

The installation tutorial of mysql 8.0.11 winx64 ...

Analysis of the principle of Nginx using Lua module to implement WAF

Table of contents 1. Background of WAF 2. What is...

JS implements simple example code to control video playback speed

introduction I discovered a problem before: somet...

Detailed explanation of Java calling ffmpeg to convert video format to flv

Detailed explanation of Java calling ffmpeg to co...