zoukankan      html  css  js  c++  java
  • 《Linux防火墙配置》

    CentOS 7

    1.防火墙操作
    启动: systemctl start firewalld
    查看状态: systemctl status firewalld
    停止: systemctl disable firewalld
    禁用: systemctl stop firewalld
    2.开放指定端口
    firewall-cmd --zone=public --add-port=80/tcp --permanent //开放端口
    firewall-cmd --reload //重新载入,使其生效
    3.关闭指定端口
    firewall-cmd --zone=public --remove-port=80/tcp --permanent //关闭端口
    firewall-cmd --reload //重新载入,使其生效
    4.查看端口状态
    firewall-cmd --zone=public --query-port=80/tcp //查看端口状态
    ---------------------
    5.放行指定IP
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.31.250.7" accept"
    #重新载入
    firewall-cmd --reload
     
    6.删除端口:
    firewall-cmd --zone=public --remove-port=3306/tcp --permanent
     
    firewall-cmd --permanent --add-port=10051/tcp --add-rich-rule="rule family="ipv4" source address="10.0.0.0/16" accept"
     
     
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.31.250.43" accept"
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.31.250.44" accept"
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.31.250.45" accept"
     
     
    #Step2:对指定IP和端口开放
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.31.2.225" port protocol="tcp" port="10051" accept"

    iptables配置

    1.删除规则
    通过 iptables -L -n --line-number 可以显示规则和相对应的编号
    iptables -L -n --line-number
    删除:
    iptables -D INPUT 2
     
    删除INPUT链编号为2的规则。
    再 iptables -L -n 查看一下 已经被清除了。
     
     
    2. 允许192.168.0.0网段访问22端口

    iptables -A INPUT -p tcp --dport 22 --source 192.168.0.0/24 -j ACCEPT

  • 相关阅读:
    合并报表优化记录
    如何在后台代码中执行原生sql?
    eclipse从数据库逆向生成Hibernate实体类
    用Eclipse进行远程Debug代码
    hibernate自动生成数据库表
    hibernate自动生成数据库表
    php通过UNIX源码编译安装
    php设置方法
    php其他配制选项
    终于做出了目录认证!
  • 原文地址:https://www.cnblogs.com/wlike/p/14292385.html
Copyright © 2011-2022 走看看