Home  >  Article  >  Operation and Maintenance  >  Detailed explanation of CentOS firewalld (firewall) instructions

Detailed explanation of CentOS firewalld (firewall) instructions

藏色散人
藏色散人forward
2020-07-03 13:37:072742browse

The following column centos system tutorial will introduce CentOS firewalld (firewall) instructions to everyone. I hope it will be helpful to friends in need!

Detailed explanation of CentOS firewalld (firewall) instructions

CentOS firewalld (firewall) command

1. View firewalld status

Check the firewalld service status command:

systemctl status firewalld

Detailed explanation of CentOS firewalld (firewall) instructions

Check the firewalld status command:

firewall-cmd --state

Detailed explanation of CentOS firewalld (firewall) instructions

2. Turn on, Restart and shut down the firewalld service

Open:

service firewalld start

Close:

service firewalld stop

Restart:

service firewalld restart

Detailed explanation of CentOS firewalld (firewall) instructions

3. Query, open and close firewalld ports

Query all open ports:

firewall-cmd --list-all

Detailed explanation of CentOS firewalld (firewall) instructions

Query whether a certain port is open :

firewall-cmd --query-port=[端口]/tcp

Detailed explanation of CentOS firewalld (firewall) instructions

Open port:

firewall-cmd --permanent --add-port=[端口]/tcp

Close port:

firewall-cmd --permanent --remove-port=[端口]/tcp

Refresh service (refresh is required after opening and closing port operations to take effect ):

firewall-cmd --reload

Detailed explanation of CentOS firewalld (firewall) instructions

PS: Error ModuleNotFoundError: No module named 'gi'

Execute command: sudo vim /usr/bin/firewall-cmd, open Modify the first line of python in the file to python2

For more centos related technical articles, please visit the centos basic tutorial column!

The above is the detailed content of Detailed explanation of CentOS firewalld (firewall) instructions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete