zoukankan      html  css  js  c++  java
  • CentOS7配置防火墙

    CentOS7配置防火墙的两种方法:

        一、使用xml配置文件的方式配置;

    方法一
    cp /usr/lib/firewalld/services/http.xml /etc/firewalld/services/
    firewall-cmd --reload

        二、使用命令的方式配置;

    方法二
    ##查看
    firewall-cmd --permanent --zone=public --list-services //服务空格隔开 例如 dhcpv6-client https ss
    firewall-cmd --permanent --zone=public --list-ports //端口空格隔开 例如 8080-8081/tcp 8388/tcp 80/tcp
     
    ##Add
    firewall-cmd --permanent --zone=public --add-port=80/tcp

    ##Remove
    firewall-cmd --permanent --zone=public --remove-port=80/tcp

    ##Reload
    firewall-cmd --reload
    命令含义:
     
        --zone #作用域
     
        --add-port=80/tcp  #添加端口,格式为:端口/通讯协议
     
       --permanent   #永久生效,没有此参数重启后失效

       

        其中,方法二的配置方式是间接修改/etc/firewalld/zones/public.xml文件,

        方案一也需要在public.xml里面新增<service name="http"/>,否则http的防火墙规则不会生效,

        而且两种配置方式都需要重新载入防火墙。

       附:

    查看防火墙状态
    systemctl status firewalld.service
    启动防火墙
    systemctl start firewalld.service
    关闭防火墙
    systemctl stop firewalld.service
    重新启动防火墙
    systemctl restart firewalld.service
  • 相关阅读:
    Design and Analysis of Algorithms_Decrease-and-Conquer
    TCPL 札记
    谬论:64 = 65?
    二叉树内部顶点与外部顶点在数量上的关系
    Design and Analysis of Algorithms_Divide-and-Conquer
    LeetCode 36. Valid Sudoku
    LeetCode 58. Length of Last Word
    LeetCode 66. Plus One
    LeetCode 67. Add Binary
    LeetCode 70. Climbing Stairs
  • 原文地址:https://www.cnblogs.com/zongyl/p/9145883.html
Copyright © 2011-2022 走看看