OpenVPN IPV6隧道Radvd

我有一个关于ipv6 + openvpn的有趣问题..

我的版本是OpenVPN 2.1.1

我已经有2个本地/ 64个ipv6networking

Block1 – > 2a01:abc:123:deac :: / 64

Block2 – > 2a01:abc:123:dead :: / 64

网关 – > 2a01:abc:123:deaf :: 1/59 )*我无法控制这个*

该计划是,通过openvpn路由这个“Block2”并进入办公室(用于testing目的)

Soo来解释..

我有一个Centos Box作为第一个Linux的“路由器”在一个数据中心和一个Ubuntu的盒子作为第二个Linux“路由器”在办公室我创build了一个简单的点对点隧道使用tun(基于closuresipv4地址启动隧道 )

我已经分配给Centos

ip addr add 2a01:abc:123:dead::1/64 dev eth0 ip addr add fed0::2/128 dev tun0 ip route add 2a01:abc:123:dead::/64 dev tun0 ## ipv6 Block2 down the tunnel ip route add ::/0 via 2a01:abc:123:deaf::1 dev eth0 ## Default out to Gateway 

我已经分配到Ubuntu

 ip addr add fed0::3/128 dev tun0 ip addr add 2a01:abc:123:dead::2/64 dev eth0 ip route add ::/0 via 2a01:abc:123:deaf::1 dev tun0 ## Default up the tunnel 

我也包括在这两个服务器上..

 sysctl -w net.inet6.ip6.forwarding=1 

看起来不错…对吗? 错了.. 🙁

我无法从Ubuntu-eth0上ping网关或2a01:abc:123:dead :: 1

我可以从任何Centos Box上的ipv6接口访问互联网,但显然不是从Ubuntu的盒子。

另外,我最终将在Ubuntu的box eth0上运行radvd,并使用ipv6地址自动configurationnetworking

任何人有一些build议/提示,以帮助我..

干杯

你的问题真的让我迷上了,因为我可能在我正在pipe理的另一个networking中使用相同的解决scheme。 我试了一下,确实有可能! (我只是喜欢Linux …)。

我创build了一个模拟你的情况的Netkit实验室。 你可以在这里下载实验室(1.8 KiB)。

如果您不想在您的机器上进行testing,则无需安装Netkit。 你可以得到上面的包,看到各种机器的.startup文件。 如果你想testing实验室,它需要一个安装有“radvd”的文件系统,这个文件系统不包含在Netkit的标准文件系统中。 检查文件系统包的README文件,看看如何将它安装到你的机器上,然后使用apt-get update && apt-get install radvd

该实验包含6台机器: v6site (你想访问的一些V6网站), v6isp (你的ISP), r1 (你的第一台具有V4和V6连接的路由器), r2 (你的第二台通过OpenVPN连接到r1的路由器), pc1pc2 (通过r2连接和服务IPv6的机器)。

我在示例中使用了RFC 3849文档前缀2001:DB8 :: / 32,而不是您使用的随机示例地址。 另外,我使用FEC0 :: / 96作为过时的OpenVPN端点。 在部署中,build议您使用唯一本地地址中的小前缀。


说明: RFC 3849定义了前缀2001:DB8 :: / 32,用于示例和文档目的(用于全球单播)。 我们鼓励用户在2001:DB8 :: / 32前缀中使用地址作为通配符,而不是select任何随机的IPv6地址,而是在实际部署中将其更改为其他内容。 在这个问题中,第一个2001:acb:132:acb :: / 64,然后是2001:123:123:11a1 :: / 64。 在答案中,我刚刚用文档前缀中的地址replace了两个。 当您将答案应用于您的实际场景时,只需查找2001:DB8 :: addresses的每个出现位置,并将其replace为您的实际地址。

隧道端点也需要地址。 隧道端点中使用的地址不需要在外部可路由,因为它们只在内部使用。 您使用以FED1 ::和FED2 ::开头的地址,而我使用的是以FECO ::开头的地址。 这些地址最初是在RFC 3513中定义的。 它们相当于IPv4的私有地址10.0.0.0/8,192.168.0.0/16和172.16.0.0/12。 由于存在问题,它们在RFC 3879中被弃用,转而采用RFC 4193中的唯一本地地址(ULA)。 ULA具有对于每个最终用户唯一的“随机”前缀。 好处是,如果因为任何原因而在这些networking之间路由,例如使用隧道,他们将能够彼此交谈而不需要地址转换(例如,当使用192.168.0.0/16时,冲突可能并且确实发生)。 在此澄清之前链接的页面将帮助您创build您自己的ULA前缀(并可能注册它,但不需要注册)。

在隧道端点使用站点本地地址(如FECx或FEDx)没有实际的问题。 他们被弃用,但这并没有使他们错了。 只是推荐使用ULA。


你的第一个路由器( r1 )的整体configuration如下。 按照意见进一步了解。

 # Enable forwarding for IPv6 (between eth0 <-> tun0) sysctl -w net.ipv6.conf.all.forwarding=1 ## ISP V6 Internal network # Since there is no host specific address, we pick an address in the /64 # prefix. Note that this address is the same in two different prefixes: # ..11a1::/64 and ..11a0::/59. This requires a proxing hack in R2. # Optimally, you would have an address in the /59 prefix to use here, # outside the delegated /64 prefix. ip link set eth0 up ip addr add 2001:db8:1:11a1::1/59 dev eth0 ip route add default via 2001:db8:1:11a0::1 dev eth0 ## V4 Internet ip link set eth1 up ip addr add 192.168.1.1/24 dev eth1 ## OpenVPN tunnel via IPv4 Internet to R2 # This is the most basic configuration of OpenVPN. No encryption, no security, # no nothing. DO NOT USE THIS OUTSIDE THIS LABORATORY. openvpn --dev tun --tun-ipv6 --daemon while ! ip link show tun0 2>/dev/null do echo "Waiting for OpenVPN to connect..." sleep 1 done # Configure OpenVPN endpoints. Choose a distinct small prefix for the endpoints # and use it to route the the /64 prefix to R2. ip link set tun0 up ip addr add fec0::1/96 dev tun0 ip route add 2001:db8:1:11a1::/64 via fec0::2 dev tun0 

第二个路由器的整体configuration( r2 ):

 # Enable forwarding for IPv6 (between eth0 <-> tun0) sysctl -w net.ipv6.conf.all.forwarding=1 ## Internal Company IPv6 Network # The router address is arbitrary. ip link set eth0 up ip addr add 2001:db8:1:11a1::ffff/64 dev eth0 ## V4 Internet ip link set eth1 up ip addr add 192.168.1.2/24 dev eth1 ## OpenVPN tunnel via IPv4 Internet to R1 # This is the most basic configuration of OpenVPN. No encryption, no security, # no nothing. DO NOT USE THIS OUTSIDE THIS LABORATORY. openvpn --remote 192.168.1.1 --dev tun --tun-ipv6 --daemon # Wait for OpenVPN... while ! ip link show tun0 2>/dev/null do echo "Waiting for OpenVPN to connect..." sleep 1 done # Configure OpenVPN endpoints. See comments for R1 above. # Note that we route ALL IPv6 traffic through the tunnel. ip link set tun0 up ip addr add fec0::2/96 dev tun0 ip route add default via fec0::1 dev tun0 # R1 address is in our private network (eth0, see above), but on the other # side of the tunnel. We need a more specific route specifically for it. # Also, make this router (R2) act as a neighbor proxy so that other # machines on the private network can see R1 through the tunnel. # This is a hack that would be avoided if we had a bigger prefix than # /64, or if R1 had a host-specific address outside of the /64. ip route add 2001:db8:1:11a1::1/128 via fec0::1 dev tun0 ip neigh add proxy 2001:db8:1:11a1::1 dev eth0 ## Routing advertisement daemon # NOTE: The standard Netkit filesystem does not have radvd, it has to be # installed manually with `apt-get update && apt-get install radvd` in # the model fs. chmod 644 /etc/radvd.conf radvd 

连接到r1 (eth0)的PC的configuration非常简单,这要感谢radvd:

 sysctl -w net.ipv6.conf.all.autoconf=1 ip link set eth0 up 

这是最重要的configuration。 其他的细节(包括r2的/etc/radvd.conf的副本)在上面的实验包里。

问你的隧道经纪人/ 56或/ 48分配,至less另一个/ 64。 然后,您可以在该块的远端链接中生成一个/ 64。 如果你有多个隧道,每个隧道需要一个单独的/ 64。

我希望FED1地址只能在TUN设备上。 (站点本地地址已被弃用,不应该使用。)你可能必须在Ubuntu端指定:: 0/0的路由。 Ubuntu eth0接口使用2001:或FED1:x:地址。 RADV应该自动提取地址,但我编程。

我的configuration使用my / 48分配给LAN设备,而/ 64分配给DMZ地址。 这使得防火墙configuration更容易,因为它们处于不重叠的范围。

你的平结果是我所期望的。 你需要在Ubuntu上指定一个到FED1 :: 1的链接。 将CentOS eth0地址更改为FED1:1 :: 1,并将地址指定为/ 32s或/ 64s应该有所帮助。 您只需要知道隧道末端的链路地址。 eth0接口应该有你的2001(公共地址)。

它在Centos上的eth0是你的上行链路,它可能有一个点对点IPv6地址的上游链路的本地端。 这应该由你的6to4隧道设置来处理,这个设置也应该把默认路由添加到Internet上。

编辑:build议的configuration

Centos (服务器/networking)

  ip -6添加fe81 :: 1/64 dev tun0
 ip -6 add 2001:acb:132:acb :: 1/64 dev eth0
 ip-6通过fe81 :: 2 dev tun0添加路由(新/ 64分配) 

Ubuntu (客户端通过隧道)

通过/etc/network/interfaces

 自动tun0
 iface tun0静态
    地址fe81 :: 2
    networking掩码64
    网关fed1 :: 1 

auto eth0
iface eth0 static
地址(新/ 64分配):: 1
networking掩码64

或者手动(你可能想要在VPN启动脚本中处理tun0),但是我会用/ etc / network / interfacesconfigurationeth0

ip -6添加fe81 :: 2/64 dev tun0
ip -6 add(new / 64):: 1/64 dev eth0
ip -6通过fe81 :: 1 dev tun0添加路由默认值

在使用eth0(LAN)接口的默认ipv6路由的主机上安装radvd 。 tun0路由是手动完成的。

警告:一旦你得到这个工作,所有的IPv6电脑将具有互联网可路由地址。 确保你有一个好的防火墙,并了解你所允许的stream量。