zoukankan      html  css  js  c++  java
  • centos 7 防火墙配置和白名单问题

    查看防火墙状态:
    systemctl status firewalld

    开启防火墙并设置开机自启
    • systemctl start firewalld
    • systemctl enable firewalld

    1. 开放 22端口:

    firewall-cmd --zone=public --add-port=22/tcp --permanent

    重新载入一下:
    firewall-cmd --reload

    查看下是否生效:
    firewall-cmd --zone=public --query-port=22/tcp

    查看开放的端口:
    firewall-cmd --zone=public --list-ports

    批量开放端口:
    firewall-cmd --zone=public --add-port=100-500/tcp --permanent
    查看是否生效
    firewall-cmd --zone=public --list-rich-rules
     

    2. 插入代码:

    #!/bin/bash
    
    # enable the firewall service
    service firewalld start
    
    # config firewall to permit ip range:172.16.17.1-70, port:1521
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.0/26" port protocol="tcp" port="1521" accept'
    
    # permit 172.16.17.63, since it is broadcast address in above ip range.
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.63" port protocol="tcp" port="1521" accept'
    
    # permit 172.16.17.64-70 one by one
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.64" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.65" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.66" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.67" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.68" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.69" port protocol="tcp" port="1521" accept'
    firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="172.16.17.70" port protocol="tcp" port="1521" accept'
    
    # reload for taking effect this time
    firewall-cmd --reload

    3. 查看文件,修改规则

    vi /etc/firewalld/zones/public.xml
  • 相关阅读:
    mybatis date类型比较
    搭建 c 语言环境 1_centos6 minimal 配置 c/c++ 编译环境
    2_eclipse配置c/c++环境
    1_eclipse导入hibernate 的DTD 文件
    1_eclipse配置c/c++开发环境
    2_修改Eclipse里面的快捷键
    1_修改注释内容
    8_对象创建、static 关键字、静态变量和成员变量的区别、文档
    7_匿名对象、封装(private)、this 关键字、构造方法
    6_面向对象基础、成员变量和局部变量的区别
  • 原文地址:https://www.cnblogs.com/leolzi/p/14004457.html
Copyright © 2011-2022 走看看