V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
axiauk
V2EX  ›  DNS

DNS 已经解决 IPV4+IPV6 但是 iptables 怎么解决啊,谁能帮完善一下 ipv4+ipv6 脚本?

  •  
  •   axiauk · 2018-12-23 03:02:58 +08:00 · 823 次点击
    这是一个创建于 1922 天前的主题,其中的信息可能已经有所发展或是发生改变。
    debian 9 脚本如下只有 IPV4:使用这个文件 /root/bin/cn_rules_ipv6.conf,谁能帮完善一下 ipv4+ipv6 脚本?


    #!/bin/bash
    SOCKS_SERVER=xxx.xxx.xxx.xxx
    ipset -N chnroute hash:net maxelem 65536
    for ip in $(cat '/root/bin/cn_rules.conf'); do
    ipset add chnroute $ip
    done

    iptables -t nat -N GFWNET
    iptables -t nat -A GFWNET -d $SOCKS_SERVER -j RETURN
    iptables -t nat -A GFWNET -d 0.0.0.0/8 -j RETURN
    iptables -t nat -A GFWNET -d 10.0.0.0/8 -j RETURN
    iptables -t nat -A GFWNET -d 127.0.0.0/8 -j RETURN
    iptables -t nat -A GFWNET -d 169.254.0.0/16 -j RETURN
    iptables -t nat -A GFWNET -d 172.16.0.0/12 -j RETURN
    iptables -t nat -A GFWNET -d 192.168.0.0/16 -j RETURN
    iptables -t nat -A GFWNET -d 224.0.0.0/4 -j RETURN
    iptables -t nat -A GFWNET -d 240.0.0.0/4 -j RETURN

    iptables -t nat -A GFWNET -p tcp -m set --match-set chnroute dst -j RETURN
    iptables -t nat -A GFWNET -p icmp -m set --match-set chnroute dst -j RETURN

    iptables -t nat -A GFWNET -p tcp -j REDIRECT --to-port 1080
    iptables -t nat -A GFWNET -p icmp -j REDIRECT --to-port 1080
    iptables -t nat -A OUTPUT -p tcp -j GFWNET
    iptables -t nat -A OUTPUT -p icmp -j GFWNET
    iptables -t nat -A PREROUTING -s 192.168/16 -j GFWNET
    iptables -t nat -A POSTROUTING -s 192.168/16 -j MASQUERADE
    7 条回复    2019-01-05 22:53:32 +08:00
    mytsing520
        1
    mytsing520  
       2018-12-23 03:17:53 +08:00
    使用 ip6tables 来配置 IPv6 的规则
    axiauk
        2
    axiauk  
    OP
       2018-12-23 04:06:06 +08:00
    新手,不会写啊。
    lunksana
        3
    lunksana  
       2018-12-23 08:53:13 +08:00 via Android
    什么代理软件可以代理 ICMP?
    leoleoasd
        4
    leoleoasd  
       2018-12-23 10:43:30 +08:00
    @lunksana #3 没有吧
    ICKelin
        5
    ICKelin  
       2018-12-23 12:32:29 +08:00
    @lunksana 代理 ICMP 其实是可以的,但是可能 to c 的产品做的会比较少。
    axiauk
        6
    axiauk  
    OP
       2018-12-23 16:07:17 +08:00
    我用 xx 可以这样 icmp 可以 ping
    lqs
        7
    lqs  
       2019-01-05 22:53:32 +08:00
    wget https://gist.githubusercontent.com/lqs/22ea1087a8f162fc2d81c52e4ed6e6f7/raw/cd1b5241f4ec7bde389281b17dff409443bc57e2/gistfile1.txt -O ipset6.txt

    ipset restore <ipset6.txt

    ip6tables -t nat -A PREROUTING -d 2000::/3 -p tcp -m set ! --match-set CN6 dst -j REDIRECT --to-port 1080
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3264 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:16 · PVG 22:16 · LAX 07:16 · JFK 10:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.