zoukankan      html  css  js  c++  java
  • iptables & tcpdump


    第一部分 iptables防火墙


    ⎝⎛•‿•⎞⎠

    shell

    Shell 字符串操作
    https://blog.csdn.net/dongwuming/article/details/50605911
    Shell 取字符串变量字符数
    https://blog.csdn.net/moyuanbomo/article/details/86741998

    判断变量是否为空字符串: if [ -z "$VAR" ]; then or if [ "${#VAR}" == 0]; then or if [ "${#VAR}" -eq 0 ]; then

    vim 高级技巧

    在 Insert 模式下可以按 Ctrl + o 暂时进入 Command 模式, 执行一个命令后回到 Insert 模式
    Alt + 任意字符 可以快速进入 Command 模式并执行命令

    iptables 中文文档

    查看链表

    iptables -L --line-number
    

    向表内执行操作 -> D删除 A添加/I插入

    iptables -[D/A/I] [INPUT/OUTPUT]
    

    指向协议和端口 -> -p 协议 --dport 端口

    iptables -A INPUT -j DROP -s 59.68.37.74 -p TCP --dport 22 # 丢弃59.68.37.74连接ssh的包
    

    为规则添加注释

    -m comment --comment 烦人的蜘蛛
    

    CloudFlare IP 规则表

    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 103.31.4.0/22
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 141.101.64.0/18
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 108.162.192.0/18
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 190.93.240.0/20
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 188.114.96.0/20
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 197.234.240.0/22
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 198.41.128.0/17
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 162.158.0.0/15
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 104.16.0.0/12
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 172.64.0.0/13
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 131.0.72.0/22
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 173.245.48.0/20
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 103.21.244.0/22
    sudo iptables -A INPUT -j ACCEPT -p tcp --dport 443 -m comment --comment 'CF' -s 103.22.200.0/22
    sudo iptables -A INPUT -j DROP -p tcp --dport 443 -m comment --comment '禁止HTTPS'
    
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 103.31.4.0/22
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 141.101.64.0/18
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 108.162.192.0/18
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 190.93.240.0/20
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 188.114.96.0/20
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 197.234.240.0/22
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 198.41.128.0/17
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 162.158.0.0/15
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 104.16.0.0/12
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 172.64.0.0/13
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 131.0.72.0/22
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 173.245.48.0/20
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 103.21.244.0/22
    sudo iptables -A OUTPUT -j ACCEPT -p tcp --sport 443 -m comment --comment 'CF' -d 103.22.200.0/22
    sudo iptables -A OUTPUT -j DROP -p tcp --sport 443 -m comment --comment '禁止HTTPS'
    

    参考
    https://www.cnblogs.com/mrwuzs/p/9482729.html


    第二部分 tcpdump 网卡抓包工具


    ⎝⎛•‿•⎞⎠

    什么是tcpdump

    END

  • 相关阅读:
    .NET 4.0 中的契约式编程
    DELL安装Windows Server 2019
    Mysql 5.7.34免安装版本
    MQTT
    WPF属性
    WPF数据绑定
    git系列之(五)git stash 命令
    Vue.js
    git 对比两个分支差异
    TPL 之二 TransformBlock
  • 原文地址:https://www.cnblogs.com/develon/p/11660996.html
Copyright © 2011-2022 走看看