centOS7 view firewall status and firewall configuration

1. Firewall opening, closing, and disabling commands

(1) Set the boot to enable the firewall:

systemctl enable firewalld.service

(2) Set the boot to disable the firewall:

systemctl disable firewalld.service

(3) Start the firewall:

systemctl start firewalld

(4) Turn off the firewall:

systemctl stop firewalld

(5) Check the firewall status:

systemctl status firewalld 

2. Use firewall-cmd to configure ports

(1) Check the firewall status:

firewall-cmd --state

(2) Reload configuration:

firewall-cmd --reload

(3) View open ports:

firewall-cmd --list-ports

(4) Open the firewall port:

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

Command meaning:

  • –zone #Scope

  • –add-port=9200/tcp #Add port, the format is: port/communication protocol

  • –permanent #Permanently effective, without this parameter, it will fail after restarting

Note: After adding a port, you must reload it with the command firewall-cmd --reload to take effect

(5) Close the firewall port:

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

Guess you like

Origin blog.csdn.net/qq980338445/article/details/118000103