• iptables Chapter2


    使用multiport模块的-–sports与-–dpors时,可以指定连续的端口范围,并且能够在指定连续的端口范围的同时,指定离散的端口号
    tcp扩展模块、multiport模块、iprange扩展模块、time扩展模块
    connlimit模块控制连接数
    limit模块是对”报文到达速率”进行限制的。
    例如:iptables -t filter -I INPUT -p icmp -m limit --limit-burst 3 --limit 10/minute -j ACCEPT
    使用string扩展模块,可以指定要匹配的字符串,如果报文中包含对应的字符串,则符合匹配条件
    tcp模块的”–tcp-flags”选项是tcp头中的标志位,去匹配tcp报文的头部的标识位,然后根据标识位的实际情况实现访问控制的功能。
    例如:iptables -I INPUT -p tcp -m tcp --dport 22 --tcp-flags SYN,ACK,FIN,RST,URG,PSH SYN -j REJECT
    例如:iptables -t filter -I INPUT -p tcp -m tcp --dport 22 --syn -j REJECT
    icmp模块
    拒绝外来PING请求:iptables -t filter -I INPUT -p icmp -m icmp --icmp-type 8/0 -j REJECT
    state扩展模块:
    iptables -t filter -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -t filter -A INPUT -m state --state NEW -j DROP

    自定义链,需要被默认链引用才能够使用
    iptables -N IN_WEB
    iptables -I IN_WEB -p tcp --dport 80 -j ACCEPT
    iptables -t filter -I INPUT -p tcp --dport 8080 -j IN_WEB
    LOG动作:iptables -I INPUT -p tcp --dport 22 -m state --state NEW -j LOG --log-prefix "want-in-from-port-22"
    SNAT动作:iptables -t nat -A POSTROUTING -s 10.1.0.0/16 -j SNAT --to-source 公网IP
    DNAT动作:
    iptables -t nat -I PREROUTING -d 公网IP -p tcp --dport 公网端口 -j DNAT --to-destination 私网IP:端口号
    iptables -t nat -I PREROUTING -d 公网IP -p tcp --dport 8080 -j DNAT --to-destination 10.1.0.1:80
    iptables -t nat -A POSTROUTING -s 10.1.0.0/16 -j SNAT --to-source 公网IP
    MASQUERADE动作:iptables -t nat -A POSTROUTING -s 10.1.0.0/16 -o eth0 -j MASQUERADE
    REDIRECT动作:iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

    假设是一种超能力
  • 相关阅读:
    Linux之流程判断
    Linux之Shell变量
    Linux之RAID
    Y-Sport
    [ST2017] Lab1: Triangle type and Junit test
    [ST2017] Hw3: Prime Path
    [ST2017] Hw2: Fault, Error, Failure and test case for projects
    [SPM2017] Hw1: The outcome of my project [Deadline: 23:59:59, Mar.1, 2017]
    [ST2017] Hw1: An error from my past projects [Deadline: 23:59:59, Feb.27, 2017]
    一个使用Jmeter做接口性能测试的实战案例
  • 原文地址:https://www.cnblogs.com/Haihong72H/p/14746524.html
Copyright © 2020-2023  润新知