firewall-cmd --zone=public --add-port=80/tcp --permanent #Command meaning: --Zone # Scope --Add port=80/tcp # Add port in the format of port/communication protocol --Permanent # It takes effect permanently and will become invalid after restarting without this parameter
If you don't understand, let's be simple and rude.
<port protocol="tcp" port="1024"/> <port protocol="tcp" port="80"/> <port protocol="tcp" port="443"/> <port protocol="tcp" port="8080"/> <port protocol="udp" port="53"/> <port protocol="udp" port="68"/>
extend
Firewalld command Run, stop, disable firewalld Start: # systemctl start firewalld Restart: # systemctl restart firewalld View status: # systemctl status firewalld or firewall cmd -- state Stop: # systemctl disable firewalld Disable: # systemctl stop firewalld Configure firewalld View version: $firewall cmd -- version View help: $firewall cmd -- help Display status: $firewall cmd -- state View area information: $firewall cmd -- get active zones View the region of the specified interface: $firewall cmd -- get zone of interface=eth0 Reject all packages: # firewall cmd -- panic on Cancel Rejection Status: # firewall cmd -- panic off Check 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 is that there is no need to disconnect. It is one of the firewalld features that dynamically adds rules. The second is that the connection needs to be disconnected, similar to restarting the service Add interfaces to the region. The default interfaces are all in public # firewall-cmd --zone=public --add-interface=eth0 Permanently effective plus permanent and reload firewall Set default interface area # firewall-cmd --set-default-zone=public Effective immediately without restarting Open the port (seems to be the 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 The method for permanent effectiveness is the same as above Open a service, which is similar to visualizing the port. The service needs to be added in the configuration file. There is a services folder in the/etc/firewalld directory, which is not detailed. For details, refer to the documentation # firewall-cmd --zone=work --add-service=smtp Remove Service # firewall-cmd --zone=work --remove-service=smtp