chinajx_dyc 发表于 2012-11-13 22:58:20

Openwrt下如何更改6to4 relay router

Buffalo WHR-G300Nv2 刷了Openwrt AA beta2之后
参照官方Wiki上的6to4 tunnel设置之后
http://wiki.openwrt.org/doc/howto/ipv6#to4.6rd
内网中的主机都能上IPv6
但是想换成上交的6to4隧道,找了半天,没有找到设置6to4 relay router的位置
在内网机器上tracert cgbt.cn如下1    12 ms    17 ms   5 ms2002:b7db:cb55:1::1
2    54 ms    59 ms    55 ms2002:c058:6301::1
3   143 ms    76 ms    72 msgige-g4-17.core1.hkg1.he.net

4    86 ms   *      113 mscernet-RGE.hkix.net
5   136 ms   139 ms   132 ms2001:252:0:101::1
6   150 ms   126 ms   143 ms2001:252:0:1::1
7   139 ms   141 ms   152 ms2001:da8:1:1c::2
8   165 ms   152 ms   *   2001:da8:1:20e::2
9   126 ms   137 ms   131 mscernet2.net
10   *      *      *   请求超时。
11   *      134 ms   *   2001:250:202:60::1
12   124 ms   138 ms   125 ms2001:250:202:70::2
13   125 ms   124 ms   135 ms2001:da8:205::100tracert ipv6.google.com1   3 ms   2 ms   6 ms2002:b7db:cb55:1::1
2    50 ms    51 ms    53 ms2002:c058:6301::1
3    44 ms    48 ms    53 msgige-g4-17.core1.hkg1.he.net

4    51 ms    47 ms    49 msgoogle3-10G.hkix.net
5    65 ms    49 ms    44 ms2001:4860::1:0:16
6    52 ms    46 ms    52 ms2001:4860::2:0:119b
7   *      *      *   请求超时。
8    46 ms    47 ms    50 ms2404:6800:4005:c00::67怎么默认走的是HE的通道?

ipconfig /allWindows IP 配置

   主机名. . . . . . . . . . . . . : dyc-PC
   主 DNS 后缀 . . . . . . . . . . . :
   节点类型. . . . . . . . . . . . : 混合
   IP 路由已启用 . . . . . . . . . . : 否
   WINS 代理已启用 . . . . . . . . . : 否
   DNS 后缀搜索列表. . . . . . . . : lan

以太网适配器 本地连接:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Atheros AR8151 PCI-E Gigabit Ethernet Con
troller
   物理地址. . . . . . . . . . . . . : C8-0A-A9-8D-9F-47
   DHCP 已启用 . . . . . . . . . . . : 是
   自动配置已启用. . . . . . . . . . : 是

以太网适配器 Bluetooth 网络连接:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Bluetooth 设备(个人区域网)
   物理地址. . . . . . . . . . . . . : F0-7B-CB-E2-6E-0F
   DHCP 已启用 . . . . . . . . . . . : 是
   自动配置已启用. . . . . . . . . . : 是

无线局域网适配器 无线网络连接:

   连接特定的 DNS 后缀 . . . . . . . : lan
   描述. . . . . . . . . . . . . . . : Qualcomm Atheros AR5B93 Wireless Network
Adapter
   物理地址. . . . . . . . . . . . . : C4-46-19-0B-F4-D8
   DHCP 已启用 . . . . . . . . . . . : 是
   自动配置已启用. . . . . . . . . . : 是
   IPv6 地址 . . . . . . . . . . . . : 2002:b7db:cb55:1:84da:16bb:5eae:ce92(首选
)
   临时 IPv6 地址. . . . . . . . . . : 2002:b7db:cb55:1:c49e:a970:e334:5bb5(首选
)
   本地链接 IPv6 地址. . . . . . . . : fe80::84da:16bb:5eae:ce92%11(首选)
   IPv4 地址 . . . . . . . . . . . . : 192.168.1.196(首选)
   子网掩码. . . . . . . . . . . . : 255.255.255.0
   获得租约的时间. . . . . . . . . : 2012年11月13日 20:52:36
   租约过期的时间. . . . . . . . . : 2012年11月14日 9:42:03
   默认网关. . . . . . . . . . . . . : fe80::126f:3fff:fe38:914a%11
                                       192.168.1.1
   DHCP 服务器 . . . . . . . . . . . : 192.168.1.1
   DNS 服务器. . . . . . . . . . . : 192.168.1.1
   TCPIP 上的 NetBIOS. . . . . . . : 已启用

无线局域网适配器 无线网络连接 4:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Microsoft Virtual WiFi Miniport Adapter
   物理地址. . . . . . . . . . . . . : 26-46-19-0B-F4-D8
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是

以太网适配器 VirtualBox Host-Only Network:

   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter
   物理地址. . . . . . . . . . . . . : 08-00-27-00-44-5F
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是
   本地链接 IPv6 地址. . . . . . . . : fe80::8995:a044:c488:3066%32(首选)
   IPv4 地址 . . . . . . . . . . . . : 192.168.56.1(首选)
   子网掩码. . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 973602855
   DHCPv6 客户端 DUID. . . . . . . : 00-01-00-01-16-9E-15-7D-C4-46-19-0B-F4-D8

   DNS 服务器. . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   TCPIP 上的 NetBIOS. . . . . . . : 已启用

隧道适配器 Teredo Tunneling Pseudo-Interface:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
   物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是

隧道适配器 Reusable ISATAP Interface {6D90DA86-72BA-4C26-9ED3-83D9277AA09A}:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Microsoft ISATAP Adapter #3
   物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是

隧道适配器 isatap.{6BAFB2E4-B37D-440C-B482-5227847135AB}:

   媒体状态. . . . . . . . . . . . : 媒体已断开
   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Microsoft ISATAP Adapter #4
   物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是

隧道适配器 isatap.lan:

   连接特定的 DNS 后缀 . . . . . . . : lan
   描述. . . . . . . . . . . . . . . : Microsoft ISATAP Adapter #6
   物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是
   本地链接 IPv6 地址. . . . . . . . : fe80::5efe:192.168.1.196%36(首选)
   默认网关. . . . . . . . . . . . . :
   DNS 服务器. . . . . . . . . . . : 192.168.1.1
   TCPIP 上的 NetBIOS. . . . . . . : 已禁用

隧道适配器 isatap.{F6FBDE01-BDD4-4D18-BD43-C7638AB708C8}:

   连接特定的 DNS 后缀 . . . . . . . :
   描述. . . . . . . . . . . . . . . : Microsoft ISATAP Adapter #5
   物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP 已启用 . . . . . . . . . . . : 否
   自动配置已启用. . . . . . . . . . : 是
   本地链接 IPv6 地址. . . . . . . . : fe80::5efe:192.168.56.1%34(首选)
   默认网关. . . . . . . . . . . . . :
   DNS 服务器. . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   TCPIP 上的 NetBIOS. . . . . . . : 已禁用netsh interface ipv6 show route发布    类型   跃点数 前缀                     索引 网关/接口名称
------- -------- ---    ------------------------ --- ------------------------
否      手动      256::/0                     11fe80::126f:3fff:fe38:914a
否      手动      256::1/128                     1Loopback Pseudo-Interface 1
否      手动      8    2002:b7db:cb55:1::/64      11无线网络连接
否      手动      2562002:b7db:cb55:1:84da:16bb:5eae:ce92/128   11无线网络连接
否      手动      2562002:b7db:cb55:1:c49e:a970:e334:5bb5/128   11无线网络连接
否      手动      256fe80::/64                  14Teredo Tunneling Pseudo-Interface
否      手动      256fe80::/64                  32VirtualBox Host-Only Network
否      手动      256fe80::/64                  15本地连接
否      手动      256fe80::/64                  13Bluetooth 网络连接
否      手动      256fe80::/64                  11无线网络连接
否      手动      256fe80::/64                  25无线网络连接 4
否      手动      256fe80::100:7f:fffe/128      14Teredo Tunneling Pseudo-Interface
否      手动      256fe80::5efe:192.168.1.196/128   36isatap.lan
否      手动      256fe80::5efe:192.168.56.1/128   34isatap.{F6FBDE01-BDD4-4D18-BD43-C7638AB708C8}
否      手动      256fe80::5c8:cc21:56be:4782/128   13Bluetooth 网络连接

否      手动      256fe80::3989:4b2f:5c4:f454/128   15本地连接
否      手动      256fe80::84da:16bb:5eae:ce92/128   11无线网络连接
否      手动      256fe80::8995:a044:c488:3066/128   32VirtualBox Host-Only Network
否      手动      256fe80::f594:4f93:dca7:be4b/128   25无线网络连接 4
否      手动      256ff00::/8                  1Loopback Pseudo-Interface 1
否      手动      256ff00::/8                   14Teredo Tunneling Pseudo-Interface
否      手动      256ff00::/8                   32VirtualBox Host-Only Network
否      手动      256ff00::/8                   15本地连接
否      手动      256ff00::/8                   13Bluetooth 网络连接
否      手动      256ff00::/8                   11无线网络连接
否      手动      256ff00::/8                   25无线网络连接 4

满天星 发表于 2012-11-14 15:44:20

没用过OP上的6to4,应该是OP上面的6to4软件包默认封装的就是HE.NET的tunnel,我猜测可能需要自己修改source code或相关的配置文件吧。你找找看是否有相关的配置,如没有只能找找source code了

chinajx_dyc 发表于 2012-11-14 18:57:44

满天星 发表于 2012-11-14 15:44 static/image/common/back.gif
没用过OP上的6to4,应该是OP上面的6to4软件包默认封装的就是HE.NET的tunnel,我猜测可能需要自己修改source...

这个是6to4包里面提取出来的脚本#!/bin/sh
# 6to4.sh - IPv6-in-IPv4 tunnel backend
# Copyright (c) 2010-2012 OpenWrt.org

[ -n "$INCLUDE_ONLY" ] || {
        . /lib/functions.sh
        . /lib/functions/network.sh
        . ../netifd-proto.sh
        init_proto "$@"
}

find_6to4_prefix() {
        local ip4="$1"
        local oIFS="$IFS"; IFS="."; set -- $ip4; IFS="$oIFS"

        printf "2002:%02x%02x:%02x%02x\n" $1 $2 $3 $4
}

test_6to4_rfc1918()
{
        local oIFS="$IFS"; IFS="."; set -- $1; IFS="$oIFS"
        [ $1 -eq10 ] && return 0
        [ $1 -eq 192 ] && [ $2 -eq 168 ] && return 0
        [ $1 -eq 172 ] && [ $2 -ge16 ] && [ $2 -le31 ] && return 0

        # RFC 6598
        [ $1 -eq 100 ] && [ $2 -ge64 ] && [ $2 -le 127 ] && return 0

        return 1
}

set_6to4_radvd_interface() {
        local cfgid="$1"
        local lanif="${2:-lan}"
        local ifmtu="${3:-1280}"
        local ifsection=""

        find_ifsection() {
                local net
                local cfg="$1"
                config_get net "$cfg" interface

                [ "$net" = "$lanif" ] && {
                        ifsection="$cfg"
                        return 1
                }
        }

        config_foreach find_ifsection interface

        [ -z "$ifsection" ] && {
                ifsection="iface_$sid"
                uci_set_state radvd "$ifsection" "" interface
                uci_set_state radvd "$ifsection" interface "$lanif"
        }

        uci_set_state radvd "$ifsection" ignore            0
        uci_set_state radvd "$ifsection" IgnoreIfMissing   1
        uci_set_state radvd "$ifsection" AdvSendAdvert   1
        uci_set_state radvd "$ifsection" MaxRtrAdvInterval 30
        uci_set_state radvd "$ifsection" AdvLinkMTU      "$ifmtu"
}

set_6to4_radvd_prefix() {
        local cfgid="$1"
        local lanif="${2:-lan}"
        local wanif="${3:-wan}"
        local prefix="${4:-0:0:0:1::/64}"
        local vlt="${5:-300}"
        local plt="${6:-120}"
        local pfxsection=""

        find_pfxsection() {
                local net base
                local cfg="$1"
                config_get net"$cfg" interface
                config_get base "$cfg" Base6to4Interface

                [ "$net" = "$lanif" ] && [ "$base" = "$wanif" ] && {
                        pfxsection="$cfg"
                        return 1
                }
        }

        config_foreach find_pfxsection prefix

        [ -z "$pfxsection" ] && {
                pfxsection="prefix_${sid}_${lanif}"
                uci_set_state radvd "$pfxsection" ""                   prefix
                uci_set_state radvd "$pfxsection" ignore               0
                uci_set_state radvd "$pfxsection" interface            "$lanif"
                uci_set_state radvd "$pfxsection" prefix               "$prefix"
                uci_set_state radvd "$pfxsection" AdvOnLink            1
                uci_set_state radvd "$pfxsection" AdvAutonomous      1
                uci_set_state radvd "$pfxsection" AdvValidLifetime   "$vlt"
                uci_set_state radvd "$pfxsection" AdvPreferredLifetime "$plt"
                uci_set_state radvd "$pfxsection" Base6to4Interface    "$wanif"
        }
}

proto_6to4_setup() {
        local cfg="$1"
        local iface="$2"
        local link="6to4-$cfg"

        local mtu ttl ipaddr adv_subnet adv_interface adv_valid_lifetime adv_preferred_lifetime
        json_get_vars mtu ttl ipaddr adv_subnet adv_interface adv_valid_lifetime adv_preferred_lifetime

        ( proto_add_host_dependency "$cfg" 0.0.0.0 )

        local wanif
        if ! network_find_wan wanif; then
                proto_notify_error "$cfg" "NO_WAN_LINK"
                return
        fi

        [ -z "$ipaddr" ] && {
                if ! network_get_ipaddr ipaddr "$wanif"; then
                        proto_notify_error "$cfg" "NO_WAN_ADDRESS"
                        return
                fi
        }

        test_6to4_rfc1918 "$ipaddr" && {
                proto_notify_error "$cfg" "INVALID_LOCAL_ADDRESS"
                return
        }

        # find our local prefix
        local prefix6=$(find_6to4_prefix "$ipaddr")
        local local6="$prefix6::1"

        proto_init_update "$link" 1
        proto_add_ipv6_address "$local6" 16
        proto_add_ipv6_route "::" 0 "::192.88.99.1"

        proto_add_tunnel
        json_add_string mode sit
        json_add_int mtu "${mtu:-1280}"
        json_add_int ttl "${ttl:-64}"
        json_add_string local "$ipaddr"
        proto_close_tunnel

        proto_send_update "$cfg"

        [ -f /etc/config/radvd ] && /etc/init.d/radvd enabled && {
                local sid="6to4_$cfg"

                uci_revert_state radvd
                config_load radvd

                adv_subnet=$((0x${adv_subnet:-1}))

                local adv_subnets=""

                for adv_interface in ${adv_interface:-lan}; do
                        local adv_ifname
                        network_get_device adv_ifname "${adv_interface:-lan}" || continue

                        local subnet6="$(printf "%s:%x::1/64" "$prefix6" $adv_subnet)"

                        logger -t "$link" " * Advertising IPv6 subnet $subnet6 on ${adv_interface:-lan} ($adv_ifname)"
                        ip -6 addr add $subnet6 dev $adv_ifname

                        set_6to4_radvd_interface "$sid" "$adv_interface" "$mtu"
                        set_6to4_radvd_prefix    "$sid" "$adv_interface" \
                                "$wanif" "$(printf "0:0:0:%x::/64" $adv_subnet)" \
                                "$adv_valid_lifetime" "$adv_preferred_lifetime"

                        adv_subnets="${adv_subnets:+$adv_subnets }$adv_ifname:$subnet6"
                        adv_subnet=$(($adv_subnet + 1))
                done

                uci_set_state network "$cfg" adv_subnets "$adv_subnets"

                /etc/init.d/radvd restart
        }
}

proto_6to4_teardown() {
        local cfg="$1"
        local link="6to4-$cfg"

        local adv_subnets=$(uci_get_state network "$cfg" adv_subnets)

        grep -qs "^ *$link:" /proc/net/dev && {
                [ -n "$adv_subnets" ] && {
                        uci_revert_state radvd
                        /etc/init.d/radvd enabled && /etc/init.d/radvd restart
                }
        }
}

proto_6to4_init_config() {
        no_device=1
        available=1

        proto_config_add_string "ipaddr"
        proto_config_add_int "mtu"
        proto_config_add_int "ttl"
        proto_config_add_string "adv_interface"
        proto_config_add_string "adv_subnet"
        proto_config_add_int "adv_valid_lifetime"
        proto_config_add_int "adv_preferred_lifetime"
}

[ -n "$INCLUDE_ONLY" ] || {
        add_protocol 6to4
}
附上6to4包
http://downloads.openwrt.org/attitude_adjustment/12.09-beta2/ar71xx/generic/packages/6to4_11-1_all.ipk

满天星 发表于 2012-11-14 19:45:18

shell脚本中135行:proto_add_ipv6_route "::" 0 "::192.88.99.1"
定义了6to4 relay的地址,请注意这个特殊的地址:192.88.99.0/24,是IANA分配的一个6to4 anycast前缀,专门用于IPV6的6to4自动隧道地址,而对应的ipv6 anycast地址为2002:C058:6301::
anycast可以自动选择最近的router来作为relay,而走HE.NET的tunnel了,也许该路径就是你所在网络的最佳方式。
如你一定要手工修改,可以尝试下,不确定现在Cernet上的6to4 relay服务是否都还可用,请自行验证!

chinajx_dyc 发表于 2012-11-14 20:54:37

满天星 发表于 2012-11-14 19:45 static/image/common/back.gif
shell脚本中135行:proto_add_ipv6_route "::" 0 "::192.88.99.1"
定义了6to4 relay的地址,请注意这个特殊 ...

噢,那nat后的主机为什么也能获取2002:段的ipv6地址呢

满天星 发表于 2012-11-16 00:37:06

废话,获取不到2002的地址,那还relay个毛线啊!
里面shell脚本里面写了,启用了radvd发布prefix,自己看吧
页: [1]
查看完整版本: Openwrt下如何更改6to4 relay router