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

  • 相关阅读:
    leetcode 18 4Sum
    leetcode 71 Simplify Path
    leetcode 10 Regular Expression Matching
    leetcode 30 Substring with Concatenation of All Words
    leetcode 355 Design Twitte
    leetcode LRU Cache
    leetcode 3Sum
    leetcode Letter Combinations of a Phone Number
    leetcode Remove Nth Node From End of List
    leetcode Valid Parentheses
  • 原文地址:https://www.cnblogs.com/wlike/p/14292385.html
Copyright © 2011-2022 走看看