zoukankan      html  css  js  c++  java
  • CentOS7使用firewalld防火墙配置端口

    安装启用firewalld防火墙

    CentOS7默认的防火墙是firewalld
    如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装

    firewalld防火墙启用与关闭

    启动systemctl start firewalld
    关闭systemctl stop firewalld
    查看状态systemctl status firewalld
    查看状态firewall-cmd --state
    开机启用systemctl enable firewalld
    开机禁用systemctl disable firewalld

    添加开放端口

    查看开放了哪些端口

    firewall-cmd --zone=public --list-ports

    添加端口

    firewall-cmd --add-port=443/tcp --permanent //永久添加443端口,协议为tcp
    firewall-cmd --reload                                       //重新加载
    

    删除端口

    firewall-cmd --zone=public --remove-port=80/tcp --permanent //删除tcp下的80端口

    参数介绍:
    firewall-cmd:是Linux提供的操作firewall的一个工具(注意没有字母“d”);
    --permanent:表示设置为持久;
    --add-port:标识添加的端口
    --remove-port:标识删除的端口

    配置文件

    firewalld的默认区域配置文件位置在/etc/firewalld/zones/下的.xml文件中,如下图:

    另外,firewall中有Zone的概念,可以将具体的端口制定到具体的zone配置文件中。
    例如:添加8010端口

    firewall-cmd --zone=public --permanent --add-port=8010/tcp  
    // --zone=public:指定的zone为public;
    

    systemctl

    systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
    启动一个服务:systemctl start firewalld.service
    关闭一个服务:systemctl stop firewalld.service
    重启一个服务:systemctl restart firewalld.service
    显示一个服务的状态:systemctl status firewalld.service
    在开机时启用一个服务:systemctl enable firewalld.service
    在开机时禁用一个服务:systemctl disable firewalld.service
    查看服务是否开机启动:systemctl is-enabled firewalld.service
    查看已启动的服务列表:systemctl list-unit-files|grep enabled
    查看启动失败的服务列表:systemctl --failed

  • 相关阅读:
    datepicker 日期连续选择(需要改源码)
    js 闭包 详解
    chorme模拟微信浏览器
    用phpmailer发邮件 中文乱码问题解决
    微信公众号-开发者-自定义菜单-CLICK事件处理
    微信公众号-开发者-自定义菜单
    腾讯创始人谈风投经验:这9种公司不能投
    微信公众号-个人开发者中心接口权限
    wamp Server2.5 配置 自定义目录
    amcharts 网页绘图插件
  • 原文地址:https://www.cnblogs.com/mingyue5826/p/10270246.html
Copyright © 2011-2022 走看看