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

How to perform query caching in MySQL and how to solve failures

We all know that we need to understand the proper...

3 ways to add links to HTML select tags

The first one : Copy code The code is as follows: ...

Detailed explanation of various HTTP return status codes

When a request is sent to your server to display ...

RHCE installs Apache and accesses IP with a browser

1. at is configured to write "This is a at t...

Understanding of CSS selector weight (personal test)

Copy code The code is as follows: <style type=...

Implementing password box verification information based on JavaScript

This article example shares the specific code of ...

Tips for importing csv, excel or sql files into MySQL

1. Import csv file Use the following command: 1.m...

VMware12 installs Ubuntu19.04 desktop version (installation tutorial)

1. Experimental description In the virtual machin...

MySQL Query Cache and Buffer Pool

1. Caches - Query Cache The following figure is p...

Datagrip2020 fails to download MySQL driver

If you cannot download it by clicking downloadlao...

How to implement Hover drop-down menu with CSS

As usual, today I will talk about a very practica...

JavaScript Advanced Programming: Variables and Scope

Table of contents 1. Original value and reference...

Mysql SQL statement operation to add or modify primary key

Add table fields alter table table1 add transacto...

Problem record of using vue+echarts chart

Preface echarts is my most commonly used charting...