如何将原生 ipv6 与 6to4 结合使用?我丢失了数据包

如何将原生 ipv6 与 6to4 结合使用?我丢失了数据包

我发现我无法将本机 IPV6 接口(在 eth0)与 6to4 隧道(在 tun6to4)一起运行。

这是我的设置(/etc/network/interfaces/):

auto eth0
auto bond0

iface eth0 inet static
    address 57.164.26.201
    netmask 255.255.255.0
    network 57.164.26.0
    broadcast 57.164.26.255
    gateway 57.164.26.254

iface eth0 inet6 static
    address 2001:5f45:2:1973::2
    netmask 64
    post-up /sbin/ip -6 r add default via 2001:5f45:2:19ff:ff:ff:ff:ff dev eth0

iface bond0 inet static
    address 57.164.25.173
    netmask 255.255.255.0

当我 ping6 -I eth0 google.com 时 - 我得到:

PING google.com(iad23s40-in-x0e.1e100.net) from 2001:5f45:2:1973::3 eth0: 56 data bytes
64 bytes from iad23s40-in-x0e.1e100.net: icmp_seq=1 ttl=55 time=81.1 ms
64 bytes from iad23s40-in-x0e.1e100.net: icmp_seq=2 ttl=55 time=81.1 ms
64 bytes from iad23s40-in-x0e.1e100.net: icmp_seq=3 ttl=55 time=81.0 ms
64 bytes from iad23s40-in-x0e.1e100.net: icmp_seq=4 ttl=55 time=81.0 ms
64 bytes from iad23s40-in-x0e.1e100.net: icmp_seq=5 ttl=55 time=81.0 ms
^C
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 81.082/81.099/81.123/0.312 ms

运行此命令后:

/sbin/ip tunnel add tun6to4 mode sit ttl 62 remote any local 57.164.25.173
/sbin/ip link set dev tun6to4 up
/sbin/ip -6 addr add 2002:39a4:19ad::1/16 dev tun6to4
/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1

我在两个 IPV6 接口的 ping 中都遇到了 100% 的数据包丢失(尽管有时很少有数据包到达谷歌的 ipv6......)。

/etc/sysctl.conf

net.ipv6.conf.eth0.disable_ipv6=0
net.ipv6.conf.eth0.autoconf=1
net.ipv6.conf.eth0.accept_ra=1
net.ipv6.conf.eth0.accept_ra_defrtr=1

我在 /etc/network/if-up.d/ipv6-routes 中找到了此脚本

#!/bin/sh
# This script sets up the IPv6 connectivity by setting the default route.
# Matching entries in /etc/network/interfaces might not work when the boot
# process is parallelized, because eth0 is not up
# quickly enough.
[ -n "${ADDRFAM}" -a "${ADDRFAM}" != 'inet6' ] && exit 0
[ -n "${IFACE}" -a "${IFACE}" != "eth0" ] && exit 0
sleep 5
/sbin/ip -family inet6 route add 2001:5f45:2:19ff:ff:ff:ff:ff dev eth0
/sbin/ip -family inet6 route add default via 2001:5f45:2:19ff:ff:ff:ff:ff
exit 0

似乎各种不同的途径都会导致这种情况发生,导致没有一种途径可以正常工作。我该如何解决?请帮忙。运行 Debian 7 Wheezy。

编辑: 我找到了 6to4 的一个简单解决方案:/etc/network/interfaces/

auto 6to4
iface 6to4 inet6 6to4
        local 57.164.25.173
ifup 6to4

在控制台中运行 ifup 6to4 之后,运行以下命令:

echo "200 sixtofour" >> /etc/iproute2/rt_tables
ip -6 rule add from 2002::/16 table sixtofour
ip -6 route add 2002::/16 dev 6to4 table sixtofour
ip -6 route add default via ::192.88.99.1 dev 6to4 table sixtofour

此后,Native 和 6to4 ipv6 接口最终都可以 ping6 google.com ...

但是……这似乎还没有结束。我在任何 ipv6 接口上都发现了少量(从 0 到 3-5 甚至在某些尝试中为 10-12%)的数据包丢失。在一些 ping6 测试中,它运行非常顺畅且没有任何错误,但有时我会在 10-11 个数据包中丢失 1 个。我知道我的 6to4 性能在很大程度上取决于互联网上用于任播地址的多个公共 6to4 中继,因此几乎不可能找出哪个中继可能导致数据包丢失。而且切换隧道代理可能是更好的方法。但我也知道有些人同时使用 ipv6 隧道代理和 6to4 接口,并且还有更多更复杂的设置和各种附加设备。

看来 Linux 中的网络路由对于这样的设置非常重要,而我在这方面还算是新手。

顺便提一句:我还发现了什么

Interrupt:20 Memory:fe500000-fe520000

当我在控制台中运行 ifconfig 时,eth0 中的行。

我只是希望可以剩下一些可以修复它的事情,例如:

  • 改变 TTL;
  • 为 eth0 ipv6 接口添加路由表
  • 运行 ndppd;

和/或“多”一点?

我非常感谢您的帮助。

第二部分结束。未完待续

答案1

尝试使用 6in4 隧道代理来获取 IPv6 连接。它更可靠,并且在这种情况下可以正常工作。据我所知,代理提供免费隧道。

升级很快,而且相对轻松。多年来,我一直在 eth0 上使用 IPv6 的 6in4。

相关内容