IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    为局域网内的电脑配置IPv6地址

    诡谲发表于 2013-02-24 17:13:22
    love 0

    IPv6是下一代互联网的IP协议,首先了解增加IPv6常用的方式,第三方软件就不说了。第一种:使用微软的Teredo隧道,目前个人测试结果是已经EOL了;第二种:isatap隧道,不支持NAT后的主机;第三种:6to4隧道,同样不支持NAT后的主机;第四种:隧道代理,例如Hurricane Electric Tunnel Broker。

    本篇基于第四种IPv6隧道代理开展,首先去注册个隧道代理,推荐Hurricane Electric Tunnel Broker。
    Hurricane Electric Tunnel Broker

    创建好之后,会把你当前的IPv4地址作为默认的Endpoint地址,即可开始使用。这里有四个需要注意的信息点:
    Server IPv4 Address => HE.net的服务端IPv4地址
    Server IPv6 Address => HE.net分配给你的服务端IPv6地址
    Client IPv4 Address => 你需要指定的当前IPv4地址
    Client IPv6 Address => HE.net分配给你的客户端IPv6地址

    首先:需要为本机指定一个静态IP地址,登录网关开放转发41协议(不是41端口)到你的静态IP地址上,如果网关路由不支持iptables自定义,可以找找路由器是否有DMZ,如果有,将其设定为你的静态IP地址。然后执行命令创建IPv6接口。

    下述出现的IPV4_SERVER对应Server IPv4 Address,IPV6_SERVER对应Server IPv6 Address,IPV6_LOCAL对应Client IPv6 Address,IPV4_LAN则是你在路由器上设置的静态IP地址

    1.Linux系列
    ip tunnel del he-ipv6
    modprobe ipv6
    ip tunnel add he-ipv6 mode sit remote $IPV4_SERVER local $IPV4_LAN ttl 255
    ip addr add $IPV6_LOCAL/64 dev he-ipv6
    ip link set he-ipv6 up
    ip ro add ::/0 dev he-ipv6
    ip -f inet6 addr

    2.WINDOWS 7
    netsh interface teredo set state disabled
    netsh interface ipv6 add v6v4tunnel IP6Tunnel %IPV4_LAN% %IPV4_SERVER%
    netsh interface ipv6 add address IP6Tunnel %IPV6_LOCAL%
    netsh interface ipv6 add route ::/0 IP6Tunnel %IPV6_SERVER%
    netsh interface ipv6 set prefix ::1/128 50 0
    netsh interface ipv6 set prefix ::/0 40 1
    netsh interface ipv6 set prefix 2002::/16 30 1
    netsh interface ipv6 set prefix ::/96 20 3
    netsh interface ipv6 set prefix ::ffff:0:0/96 10 4
    netsh interface ipv6 set prefix 2001::/32 5 1
    netsh interface ipv6 add dnsservers "IP6Tunnel" 2001:470:20::2 validate=no

    3.FreeBSD
    ifconfig gif0 create
    ifconfig gif0 tunnel $IPV4_LAN $IPV4_SERVER
    ifconfig gif0 inet6 $IPV6_LOCAL $IPV6_SERVER prefixlen 128
    route add -inet6 ::/0 $IPV6_SERVER
    ifconfig gif0 up

    执行成功后访问http://test-ipv6.com/就应该可以看到IPv6地址了。
    test-ipv6

    进阶练习

    上述是通用的配置方法,一般在路由器做了穿透后就可以使用了。但每次本地公网IP变更就要到Hurricane Electric Tunnel Broker管理界面更新Endpoint IP,这遭罪啊。想想办法吧!OK,Hurricane Electric Tunnel Broker提供了API:https://ipv4.tunnelbroker.net/ipv4_end.php,使用方法:

    -ERROR: Missing parameter(s).
    Usage: https://ipv4.tunnelbroker.net/ipv4_end.php?ip=IPV4ADDR&pass;=MD5PASS&apikey;=USERID&tid;=TUNNELID
    -or-: https://USERNAME:PASSWORD@ipv4.tunnelbroker.net/ipv4_end.php?tid=TUNNELID (auto-detect IP)

    https://USERNAME:PASSWORD@ipv4.tunnelbroker.net/ipv4_end.php?tid=TUNNELID&ip=IPV4ADDR

    IPV4ADDR: Your IPv4 endpoint. Set to AUTO to determine your IP based on the IP you requested this page from. Previously passed as ipv4b.
    MD5PASS : The MD5 hash of your password. You may be able to 'echo -n YOURPASSWORD | md5sum' to produce the MD5 hash of your password.
    USERID : The UserID shown on the main page of tunnelbroker.net when you log in. Previously referred to as user_id.
    TUNNELID: The ID of the tunnel you're updating the endpoint on. This can be found on the tunnel information page. Previously referred to as the Global Tunnel ID / tunnel_id.

    The following parameters are only usable when accessing this script over https.
    USERNAME: Your tunnelbroker.net username.
    PASSWORD: Your tunnelbroker.net password.

    The legacy parameter names will continue to work for the forseable future. Naming of them changed to be more in line with industry convention and their roles.

    现在,你可以用你想得到的方法更新IP了。例如你可以写一个动态网页放服务器去,更换了IP就去访问它;又或者你可以写一个检测IP变化的脚本丢路由器去,都可以解决公网IP更新的问题。End



沪ICP备19023445号-2号
友情链接