Turn on port 80
1.Firewall-cmd --zone=public --add-port=/tcp --permanent Success appears to indicate added success
Command meaning:
--zone #作用域
--add-port=80/tcp #添加端口 in the format: Port/Communication protocol
--permanent #永久生效, fail after reboot without this parameter
Restarting the firewall
1.systemctl Restart Firewalld.service1. Run, stop, disable FIREWALLD
Start: # systemctl start Firewalld
View Status: # Systemctl status Firewalld or Firewall-cmd--state
Stop: # systemctl Disable FIREWALLD
Disable: # Systemctl stop Firewalld
2, Configuration Firewalld
View version: $ firewall-cmd--version
View Help: $ firewall-cmd--help
To view the settings:
Display Status: $ firewall-cmd--state
View area information: $ firewall-cmd--get-active-zones
View the specified interface zone: $ firewall-cmd--get-zone-of-interface=eth0
Reject All Packages: # Firewall-cmd--panic-on
Cancel deny status: # Firewall-cmd--panic-off
To see whether to reject: $ firewall-cmd--query-panic
Update firewall rules: # firewall-cmd--reload
# Firewall-cmd--complete-reload
The difference between the two is that the first one without disconnecting, is one of the FIREWALLD features dynamically add rules, the second needs to be disconnected, similar to restart the service
Add an interface to a zone, and the default interface is in public
# Firewall-cmd--zone=public--add-interface=eth0
Permanently effective plus--permanent then reload firewall
Set the default interface area
# Firewall-cmd--set-default-zone=public
Immediate effect without restarting
Open port (looks like this is most commonly used)
To view all open ports:
# Firewall-cmd--ZONE=DMZ--list-ports
Add a port to the zone:
# Firewall-cmd--ZONE=DMZ--add-port=8080/tcp
To permanently effect the method above
Open a service, similar to the port visualization, service needs to be added in the configuration file, the/ETC/FIREWALLD directory has a Services folder, this is not detailed, the details of the reference document
# Firewall-cmd--zone=work--ADD-SERVICE=SMTP
Removal service
# Firewall-cmd--zone=work--REMOVE-SERVICE=SMTP
Centos 7 Firewall Firewalld Open 80 port