- 论坛徽章:
- 0
|
小弟遇到一个问题,困惑了好几天,具体如下。
我有一个主机,就叫A吧,双网卡,eth0上有一个公网的IP,ipv4的。通过下面的一些命令,建立ipv6 over ipv4 的隧道就可以联结到校内的IPV6网络,并且可以 pin6 ipv6.google.com 成功。
- # ip tunnel add sit1 mode sit remote $remote_addr local $local_addr
- # ifconfig sit1 up
- # ifconfig sit1 add 2001:DA8:C800:B1:0:5EFE:$local_addr
- # ip route add ::/0 via 2001:DA8:C800:B1:0:5EFE:CACA:D962 metric 1
复制代码
其中 $remote_addr 是远程的公网ip地址, $local_addr是我的主机的eth0上的公网ip,均为ipv4.
因为A是双网卡,我想把另外一台主机,假设为B,连接到 A的eth1上,想通过隧道,也联结到远端的ipv6网络,应该如何做呢? 主机A的IPV6的转发功能已经打开。
有这样的一篇文章可以参考,http://linux.chinaunix.net/bbs/viewthread.php?tid=354359,这是一篇翻译的文章,原文在这里,
http://www.deepspace6.net/docs/iproute2tunnel-en.html
里面讲到了,如何把隧道建立在一个router上,但是讲得比较模糊,或者是小弟我的理解能力有限。里面有一段是这样讲的,
5.3、隧道IP地址
当我们的计算机是一个独立主机或者不是一个提供到整个局域网IPv6连接的路由器时,为本地端节点隧道选择一个全球/公用IP地址是最好的事,分别是一个SIT/IPv6-in-IPv4隧道的IPv6地址和一个GRE/IPv4-in-IPv4隧道的IPv4地址。
取而代之,若配置一个路由器,最好让SIT/IPv6-in-IPv4隧道用一个链路本地地址(IPv6的链路本地地址可以通过无状态地址自动配置或者人工配置)和GRE/IPv4-in-IPv4隧道用一个私有地址(IPv4没有链路本地地址)。有效的地址只能用在eth0上(或者在局域网那边的接口上)。注意在配置的时候需要激活转发接口,用命令:
sysctl -w net.ipv4.conf.all.forwarding=1 # for GRE (IPv4-in-IPv4)
sysctl -w net.ipv6.conf.all.forwarding=1 # for SIT (IPv6-in-IPv4)
甚至可以决定打开在一对间转发,这种情况下,用如下命令:
sysctl -w net.ipv6.conf.eth0.forwarding=1
sysctl -w net.ipv6.conf.pippo.forwarding=1
5.3. Which IP for the tunnel
Choosing a global/public IP address (respectively an IPv6 address for SIT/IPv6-in-IPv4 tunnels and an IPv4 address for GRE/IPv4-in-IPv4 tunnels) for the local endpoint of the tunnel is probably the best thing we can do when our computer is a single host and not a router providing IPv6 connectivity to a whole LAN.
Instead, if we're configuring a router, we'd better use a link-local address for SIT/IPv6-in-IPv4 tunnels (in IPv6 link-local addresses are assigned automatically by means of stateless address autoconfiguration or manually configured) and a private address for GRE/IPv4-in-IPv4 tunnels (IPv4 has no link-local addresses). The valid address will then be only on eth0 (or the interface on the LAN side). Notice that in this configuration you need to activate forwarding among interfaces, using these commands:
sysctl -w net.ipv4.conf.all.forwarding=1 # for GRE (IPv4-in-IPv4)
sysctl -w net.ipv6.conf.all.forwarding=1 # for SIT (IPv6-in-IPv4)
For IPv4 you can even decide to enable forwarding only between a couple of interfaces, in this case you could use these commands:
sysctl -w net.ipv4.conf.eth0.forwarding=1
sysctl -w net.ipv4.conf.pippo.forwarding=1
主要就是这个绿色的部分。 说在配置一个路由器的时候,最好为sit/ipv6-in-ipv4的隧道使用 link-local的地址,link-local的地址是自动分配的ipv6的地址,似乎很难用上? 而且用link-local的地址,是不能通过router的。 迷惑几天,希望得到高手的指点。
[ 本帖最后由 futuregod 于 2008-12-5 10:59 编辑 ] |
|