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

  • 相关阅读:
    PHP 截取字符串专题
    PHP获取文件扩展名的三种方法
    PHP万能密码登陆
    js正则表达式 验证手机号,email地址和邮政编码
    图片局部链接实例,方便自己用!
    通用客户端表单验证函数修正版
    C#事件的知识,转载学习
    C# byte及char FileStream 与StreamReader的区别(转)
    .Net下二进制形式的文件(图片)的存储与读取(转载)
    高斯克吕格坐标系中国部分定义(北京五四和西安80)(转,准确性使用性不敢保证)
  • 原文地址:https://www.cnblogs.com/mingyue5826/p/10270246.html
Copyright © 2011-2022 走看看