CentOS7 USES firewalld to open and close firewalls and ports

  • 2020-05-17 07:28:58
  • OfStack

1. Basic use of firewalld

Activation:


 systemctl start firewalld

View status:


systemctl status firewalld 

Stop:


systemctl disable firewalld

Disable:


systemctl stop firewalld

2.systemctl is the main tool in CentOS7's service management tools. It integrates the functions of service and chkconfig in body 1.

Start 1 service:


systemctl start firewalld.service

Close 1 service:


systemctl stop firewalld.service

Restart 1 service:


systemctl restart firewalld.service

Display the status of a service:


systemctl status firewalld.service

Enable 1 service at startup:


systemctl enable firewalld.service

Disable 1 service when booting:


systemctl disable firewalld.service

Check whether the service starts up:


systemctl status firewalld 
0

View the list of started services:


systemctl list-unit-files|grep enabled

View the list of services that failed to start:


systemctl --failed

3. The configuration firewalld - cmd

View version:


systemctl status firewalld 
3

See help:


systemctl status firewalld 
4

Display status:


systemctl status firewalld 
5

View all open ports:


systemctl status firewalld 
6

Update firewall rules:


firewall-cmd --reload

View area information:


 firewall-cmd --get-active-zones

View the region of the specified interface:


systemctl status firewalld 
9

Reject all packages:


firewall-cmd --panic-on

Cancel reject status:


firewall-cmd --panic-off

Check whether to reject:


firewall-cmd --query-panic

How do you open a port

add


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

(--permanent is permanently in effect, and will fail after restart without this parameter)

Reload the


firewall-cmd --reload

To view


firewall-cmd --zone= public --query-port=80/tcp

delete


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

Related articles: