linux基于IPv6策略的路由失败

我有一个VPN服务器作为我的IPv6连接到互联网。 设置我们这样的:

我已经分配了一个/ 48地址池,我想要子网到我的VPN客户端。 为了参数,让我们调用池2001:DB8:CAFE::/48

我把这个networking分成了以下几部分: 2001:DB8:CAFE::/64被分配给VPN服务器和每个客户端之间的实际VPN链路。

    客户端1后面的networking分配了“2001:DB8:CAFE:100:/ 56”
    “2001:DB8:CAFE:200:/ 56”分配给客户端2后面的networking

这给了我们这个布局:

 + -------------- + 2001:470:xxxx:xxx :: / 64 + --------------- + /  - >客户端1networking(2001:DB8:CAFE:100 :: / 56)
 |  + < - 隧道经纪人链接 - > + |  /
 | 互联网|  | 我的VPN服务器+ < -  * ---> VPN链接 - networking拓扑(2001:DB8:CAFE :: / 64)
 |  + < - 本机IPv6链接---> + |  \
 + -------------- + 2a01:xxxx:xxxx:xxxx :: / 48 + --------------- + \  - > Client 2 network (2001:DB8:CAFE:200 :: / 56)

我想要的是,所有来自2001:DB8:CAFE::/48stream量2001:DB8:CAFE::/48都通过我的Tunnelbroker链接路由 – 只有那个链接

这导致我到以下脚本:

 # Reset IPv6 routing table. ip -6 rule flush # Reset Tunnelbroker routing table (table name: "he-ipv6"). ip -6 route flush table he-ipv6 # Add routeable VPN subnets to Tunnelbroker routing table ip -6 rule add from 2001:DB8:CAFE::/48 table he-ipv6 # Any traffic that originates from VPN has to be forwarded via Tunnelbroker routing table # using the tunnelbroker link (link name: he-ipv6). ip -6 route add default via 2001:470:xxxx:xxx::1 dev he-ipv6 table he-ipv6 # Add default IPv6 rules again - since they gets deleted by the initial rule flush command. ip -6 rule add priority 32766 from all table main 

但是:当我运行ip -6 route add default ... -command我收到以下错误:

RTNETLINK answers: No route to host

问题是,我可以ping 2001:470:xxxx:xxx::1之前我跑脚本,但不是之后。

我错过了什么?

Do'h! 命令的顺序很重要

命令ip -6 route add default via 2001:470:xxxx:xxx::1 dev he-ipv6 table he-ipv6没有工作是路由在main表中定义。

但是由于初始flush命令删除了主表,所以执行ip route default命令之前 ,必须重新添加它。

正确的脚本是:

 # Reset IPv6 routing table. ip -6 rule flush # Add default IPv6 rules again - since they gets deleted by the initial rule flush command. ip -6 rule add priority 32766 from all table main # Reset Tunnelbroker routing table (table name: "he-ipv6"). ip -6 route flush table he-ipv6 # Add routeable VPN subnets to Tunnelbroker routing table ip -6 rule add from 2001:DB8:CAFE::/48 table he-ipv6 # Remember to add a rule that if no machine does not respond to a # packet address in my /48, then we should return unreachable. # Else the package will be forwarded by default out through the # Hurricane Electric connection. #(From the Internet) ip -6 route add unreachable 2001:DB8:CAFE::/48 #(From my /48 subnet) ip -6 route add unreachable 2001:DB8:CAFE::/48 table mynet6 # Any traffic that originates from VPN has to be forwarded via Tunnelbroker routing table # using the tunnelbroker link (link name: he-ipv6). ip -6 route add default via 2001:470:xxxx:xxx::1 dev he-ipv6 table he-ipv6 

我将在这里留下问题和答案,因为我不是唯一一个尝试使用基于源的IPv6路由。

我在这个问题上find的最新信息是从2010年。