Something more
«
01/31/2010Note

在 NAT 后面使用 ISATAP 连接 IPv6

寒假回家想用 isatap 连接 ipv6, 但是家里是用路由器上网, isatap 默认在 NAT 后面没法正常工作. 考虑到路由器后面只有我一台机器需要 ipv6 连接, 于是开始瞎折腾, 想办法把所有 isatap 的数据全部定向到我那台机器上.
我机器的系统是 win7, 路由器系统是 openwrt brcm-2.4.

首先在路由器防火墙里面加条规则, 把收到的协议号是 41 的数据包全部重定向到我的机器上面. 像 isatap, 6to4 等协议的协议号都是 41. openwrt 可以直接修改 /etc/config/firewall :

config redirect
option src                      wan
option dest                     lan
option dest_ip          192.168.11.2
option proto            41

其他类似的系统 (如 dd-wrt 之类的) 应该可以直接用 iptables 修改.

不过改了这些之后还是上不了网. 抓包之后觉得可能是因为数据包的 link-local 地址和全局的 ipv6 地址不对, 于是用 netsh 人肉指定了一下这两个地址. 我写了个简单的 bat 来搞这件事情.

@echo off
 
set interface=isatap.lan     // 这个是我 isatap interface 的名字
set prefix="2001:da8:8000:d010"  // 我用的是上交的 isatap router
set ip="220.x.x.x"     // 这个是我路由器的外网 ip
 
for /f " tokens=2 delims=%% " %%a in ('"netsh int ipv6 show addr %interface% | findstr /r ^Address.*Parameters$"') do netsh int ipv6 del addr %interface% %%a
 
netsh int ipv6 add addr %interface% fe80::5efe:%ip%
netsh int ipv6 add addr %interface% %prefix%:0:5efe:%ip%
 
netsh int ipv6 isa s s d
netsh int ipv6 isa s s e

搞定了这些之后就可以连通 ipv6 站点了 :)

ps. 最后想了个歪办法来解决路由器后面有多个机器需要 ipv6 连接的情况, 就是每个机器用一个不同的 isatap router. :-D

Metadata »

This entry was posted on 2010-01-31 22:40 by 寒水远山 and is filed under Note. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

22 comments

  1. pluskid says:

    ym 寒仔!完全不懂…… @_@

  2. watashi says:

    zan 我要搞不定就靠你了

  3. 8884361 says:

    某人~~看到你這篇文章~~發現~~DD-WRT沒 /etc/config/firewall
    求方法~~

    • 寒水远山 says:

      在 Administration -> Commands 里面的 Firewall Commands 里面加上就好了, 大概是这样的: iptables -A XXXXXX -d 你的IP -p 41 -j DNAT –to-destination 你的内网ip. 具体是什么因为太久没用 dd-wrt 忘记了…

      • 8884361 says:

        問題外網IP每次不同~

        • 寒水远山 says:

          也是可以的~ 你可以 telnet 上去看看 NAT 是怎么改 iptables 的, 这个设置方法和 NAT 差不多, 就是协议不是 TCP/UDP, 是 41

  4. codeblue says:

    你好,博主,我用你的批没实现

    你之前有设置了交大的isatap的router了?

    202.112.26.254 ?

    批处理提示 找不到元素。xp系统

    手动设置的话,提示参数不正确 。

    可以问下,批处理为什么要这么写吗。把ipv6地址写成路由外网的。

    跟你一样的环境。openwrt 8.09.2 2.4 nat

    • 寒水远山 says:

      我之前设置了, blog里面忘记说了 T_T
      xp是哪一步提示参数不正确的?
      ipv6地址写成外网的, 返回到数据包才能正确地回来

  5. codeblue says:

    netsh int ipv6 add addr isatap.lan fe80::5efe:58.199.x.xx
    找不到元素。

    netsh int ipv6 add addr isatap.lan 2001:da8:8000:d010:0:5efe:58.199.x.xx
    找不到元素。

    =======
    提示这样。前面 set的引号我去掉了

  6. codeblue says:

    Windows IP Configuration

    Ethernet adapter 本地连接:

    Connection-specific DNS Suffix . : lan
    IP Address. . . . . . . . . . . . : 192.168.1.2
    Subnet Mask . . . . . . . . . . . : 255.255.255.0
    IP Address. . . . . . . . . . . . : fe80::21a:4bff:fe5d:cf22%4
    Default Gateway . . . . . . . . . : 192.168.1.1

    Tunnel adapter Teredo Tunneling Pseudo-Interface:

    Connection-specific DNS Suffix . :
    IP Address. . . . . . . . . . . . : fe80::ffff:ffff:fffd%5
    Default Gateway . . . . . . . . . :

    Tunnel adapter Automatic Tunneling Pseudo-Interface:

    Connection-specific DNS Suffix . : lan
    IP Address. . . . . . . . . . . . : fe80::5efe:192.168.1.2%2
    Default Gateway . . . . . . . . . :

    • 寒水远山 says:

      我这边是 Tunnel adapter isatap.lan:
      大概 “Automatic Tunneling Pseudo-Interface” 就是你电脑interface的名字..

  7. codeblue says:

    win7 跟xp 出入 比较 大。我还是先把win7的给整出来 。

  8. zz says:

    博主,前面是否先要连接上交的proxy?

  9. 自由人 says:

    楼主 我可以购买你的vpn吗?ipv6的 联系我吧 邮件

  10. 自由人 says:

    额。我想用来 玩游戏的说 挺像用的 延迟多少呀 能商量下不》?

  11. 自由人 says:

    哦 这样啊。。。。。。。。。

Reply »