Linux system [Centos7] setting firewall tutorial

1. View firewall status

Enter the following command in the terminal:

```
systemctl status firewalld
```

If the status is displayed as "active", it means that the firewall has been activated; if the status is displayed as "inactive", it means that the firewall is not activated.

2. Start the firewall

Enter the following command in the terminal:

```
systemctl start firewalld
```

3. Stop the firewall

Enter the following command in the terminal:

```
systemctl stop firewalld
```

4. Boot up and start the firewall

Enter the following command in the terminal:

```
systemctl enable firewalld
```

5. Turn off the boot firewall

Enter the following command in the terminal:

```
systemctl disable firewalld
```

6. Add port

Enter the following command in the terminal:

```
firewall-cmd --zone=public --add-port=80/tcp --permanent
```

Among them, --zone can set the firewall area, --add-port can add ports, and --permanent can save the rules permanently.

Test environment: Centos7.6 system - server from: Lanyiyun

The CN2 network of Hong Kong's five networks  has excellent domestic speed and supports functions such as VPC intranet interconnection, snapshots, and backups.

China Mobile + China Unicom + China Telecom + Education Network + Radio and Television - Five Network CN2 - ultra-low latency!

Detailed evaluation article: click me to view

 

7. Delete port

Enter the following command in the terminal:

```
firewall-cmd --zone=public --remove-port=80/tcp --permanent
```

Among them, --zone can set the firewall zone, --remove-port can delete the port, and --permanent can save the rules permanently.

8. View the added ports

Enter the following command in the terminal:

```
firewall-cmd --zone=public --list-ports
```

Among them, --zone can set the firewall zone, and --list-ports can list the added ports.

9. View firewall rules

Enter the following command in the terminal:

```
firewall-cmd --list-all
```

This command can list all firewall rules.

The above is the tutorial for setting up the system firewall in CentOS7 system. If you want to protect your server, these operations are essential.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/129947736