Operation of CentOS7 on Firewalls and Ports

https://jingyan.baidu.com/article/cdddd41cb3bf6c53cb00e1ac.html

When CentOS7 installs software packages or class libraries, connection failures, data calls or remote failures are often caused by firewall interception and port opening. Therefore, when using CentOS, you need to learn how to operate firewalls and ports. . .

 

Tools/Materials

 
  • A host with CentOS7 installed

method/step

 
  1. 1

    CentOS7 uses the systemctl command to manage a single service of the system. In CentOS7, the opening, closing and status query of the firewalld (firewall) service also uses this command. The operations are as follows:

  2. 2

    Start the firewall: systemctl start firewalld

  3. 3

    Check firewall status: systemctl status firewalld 

    Operation of CentOS7 on Firewalls and Ports
  4. 4

    Turn off the firewall: systemctl stop firewalld

    Operation of CentOS7 on Firewalls and Ports
  5. 5

    Enable firewall service at boot: systemctl enable firewalld Disable firewall service at boot: systemctl disable firewalld

    Operation of CentOS7 on Firewalls and Ports
    Operation of CentOS7 on Firewalls and Ports
  6. 6

    Query whether the firewall service is started at boot: systemctl is-enabled firewalld

    Operation of CentOS7 on Firewalls and Ports
  7. 7

    Query the list of started services: systemctl list-unit-files|grep enabled

    Operation of CentOS7 on Firewalls and Ports
  8. 8

    Query the list of services that failed to start: systemctl --failed

    Operation of CentOS7 on Firewalls and Ports
  9. 9

    When installing software or a library, in addition to directly opening and closing the firewall, you can also directly open the connection by operating the port; add a port: firewall-cmd --zone=public --add-port=80/tcp --permanent 

    Operation of CentOS7 on Firewalls and Ports
  10. 10

    Update firewall rules: firewall-cmd --reload

    View port status: firewall-cmd --zone=public --query-port=80/tcp

    Operation of CentOS7 on Firewalls and Ports
  11. 11

    Remove open ports: firewall-cmd --zone=public --remove-port=80/tcp --permanent

    Operation of CentOS7 on Firewalls and Ports
  12. 12

    Every time you update the firewall rules, you need to re-update: firewall-cmd --reload, update status;

  13. 13

    In addition, after updating the firewall settings, you can also view all open ports: firewall-cmd --zone=public --list-ports

    Operation of CentOS7 on Firewalls and Ports

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324611667&siteId=291194637