zoukankan      html  css  js  c++  java
  • 防火墙-iptables

    环境

    系统 IP 软件 备注
    centos7 don't care firewall iptables firewall系统自带 iptables需另安装
    centos6 don't care iptables iptables系统自带

    centos7-iptables

    1. 安装
    ]# systemctl stop firewalld #关闭firewall
    ]# yum install iptables iptables-services -y
    
    1. iptables设置
    ]# systemctl disable firewalld #关闭firewall自启动
    ]# systemctl start iptables.service #开启iptables
    ]# systemctl enable iptables.service #设置iptables自启动
    

    iptables使用方法

    1. 新增位置在第一行
    ]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
    
    1. 新增位置在最后一行
    ]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    
    1. 指定新增规则位置
    ]# iptables -I INPUT 2 -p tcp --dport 80 -j ACCEPT
    

    1. 按行号删除
    ]# iptables -nL --line-numbers
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source               destination         
    1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
    3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
    4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
    5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain FORWARD (policy ACCEPT)
    num  target     prot opt source               destination         
    1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain OUTPUT (policy ACCEPT)
    num  target     prot opt source               destination 
    ]# iptables -D INPUT 2
    

    1. 修改指定规则
    ]# iptables -R INPUT 2 -j DROP #将第二条规则的ACCEPT改为DROP
    

    1. 查看规则,默认表是filter
    ]# iptables -nL
    
    1. 查看规则,显示行号
    ]# iptables -nL --line-numbers
    
    1. 查看规则的详细信息
    ]# iptables -nL -v #后面'v'越多,信息越全面
    
    1. 查看指定表的规则
    ]# iptable -t raw|nat|mangle|filter -nL
    

    在此演示的是filter表中的INPUT链的规则,关于'四表五链'的详细介绍后面会作出补充

  • 相关阅读:
    【刷题】BZOJ 3626 [LNOI2014]LCA
    【刷题】UOJ #207 共价大爷游长沙
    【刷题】COGS 2701 动态树
    【刷题】BZOJ 4530 [Bjoi2014]大融合
    【刷题】BZOJ 2959 长跑
    【刷题】BZOJ 1969 [Ahoi2005]LANE 航线规划
    【刷题】BZOJ 4998 星球联盟
    【刷题】BZOJ 1977 [BeiJing2010组队]次小生成树 Tree
    【刷题】BZOJ 4817 [Sdoi2017]树点涂色
    获取元素 在网页中的 坐标
  • 原文地址:https://www.cnblogs.com/wanwz/p/12887221.html
Copyright © 2011-2022 走看看