Linux

具有未編號介面的 IPv6 路由 - 超出範圍錯誤

  • August 6, 2016

我已經建立了一個從家到遠端主機的無編號 L2tp 隧道。在嘗試 ping ipv6.google.com 時,我收到了超出範圍的錯誤,我知道在一段時間之前,不應該以這種方式使用連結本地地址,但現在使用未編號的介面應該是可能的。

兩台機器都執行最新的 debian jessie,但使用更新的核心4.6.0-0.bpo.1-amd64

隧道:

~> sudo ip l2tp show tunnel
  Tunnel 386, encap IP
  From 192.168.88.254 to remote_host
  Peer tunnel 381

地址和路線:

首頁 ~> ip -6 地址

5: l2tpeth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 state UNKNOWN qlen 1000
   inet6 fe80::8427:7dff:fea4:939b/64 scope link
      valid_lft forever preferred_lft forever
~> ip -6 route
local ::1 dev lo  proto kernel  metric 256
fe80::/64 dev vnet0  proto kernel  metric 256
fe80::/64 dev l2tpeth0  proto kernel  metric 1024
default via fe80::f94e:693a:aa66:e79b dev l2tpeth0  metric 1024

遠端主機 ~> ip -6 地址

5: l2tpeth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 state UNKNOWN qlen 1000
   inet6 fe80::f94e:693a:aa66:e79b/128 scope link
      valid_lft forever preferred_lft forever
   inet6 fe80::f434:73ff:fef3:5236/64 scope link
      valid_lft forever preferred_lft forever
~> ip -6 route
local ::1 dev lo  proto kernel  metric 256
2400:8900::/64 dev eth0  proto kernel  metric 256  expires 2591997sec mtu 1300
fe80::f94e:693a:aa66:e79b dev l2tpeth0  proto kernel  metric 256
fe80::/64 dev eth0  proto kernel  metric 256  mtu 1300
fe80::/64 dev tun0  proto kernel  metric 256
fe80::/64 dev l2tpeth0  proto kernel  metric 256  mtu 1460
default via fe80::1 dev eth0  proto ra  metric 1024  expires 87sec mtu 1500 hoplimit 64

Ping:

~> ping6 fe80::f94e:693a:aa66:e79b%l2tpeth0
PING fe80::f94e:693a:aa66:e79b%l2tpeth0(fe80::f94e:693a:aa66:e79b) 56 data bytes
64 bytes from fe80::f94e:693a:aa66:e79b: icmp_seq=1 ttl=64 time=61.9 ms
64 bytes from fe80::f94e:693a:aa66:e79b: icmp_seq=2 ttl=64 time=58.4 ms
64 bytes from fe80::f94e:693a:aa66:e79b: icmp_seq=3 ttl=64 time=57.4 ms
64 bytes from fe80::f94e:693a:aa66:e79b: icmp_seq=4 ttl=64 time=56.5 ms
64 bytes from fe80::f94e:693a:aa66:e79b: icmp_seq=5 ttl=64 time=66.1 ms
^C
--- fe80::f94e:693a:aa66:e79b%l2tpeth0 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 56.509/60.113/66.190/3.562 ms

從家裡 ping Google:

ping6 ipv6.google.com
PING ipv6.google.com(hkg12s01-in-x0e.1e100.net) 56 data bytes
From hkg12s01-in-x0e.1e100.net icmp_seq=1 Destination unreachable: Beyond scope of source address
From hkg12s01-in-x0e.1e100.net icmp_seq=2 Destination unreachable: Beyond scope of source address
^C
--- ipv6.google.com ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1001ms

遠端 tcpdump:

~> sudo tcpdump -ni l2tpeth0 icmp6
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on l2tpeth0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:34:19.944576 IP6 fe80::8427:7dff:fea4:939b > 2404:6800:4005:801::200e: ICMP6, echo request, seq 1, length 64
09:34:19.944749 IP6 fe80::f94e:693a:aa66:e79b > fe80::8427:7dff:fea4:939b: ICMP6, destination unreachable, beyond scope 2404:6800:4005:801::200e, source address fe80::8427:7dff:fea4:939b, length 112
09:34:20.946277 IP6 fe80::8427:7dff:fea4:939b > 2404:6800:4005:801::200e: ICMP6, echo request, seq 2, length 64
09:34:20.946397 IP6 fe80::f94e:693a:aa66:e79b > fe80::8427:7dff:fea4:939b: ICMP6, destination unreachable, beyond scope 2404:6800:4005:801::200e, source address fe80::8427:7dff:fea4:939b, length 112
^C
4 packets captured
4 packets received by filter
0 packets dropped by kernel

遠端主機上的 sysctl(ipv6 轉發已打開):

net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.eth0.forwarding = 1
net.ipv6.conf.l2tpeth0.forwarding = 1

Beyond scope of source address意味著您沒有足夠大範圍的 IPv6 地址來到達目的地。

特別是,您只有一個鏈路本地地址,因此您只能在該第 2 層鏈路上訪問 IPv6 地址。在這種情況下,這意味著您只能到達隧道的另一端。

為了訪問 Internet,您需要全域範圍的 IPv6 地址,並且需要將它們路由到(和從)您。您從您的 Internet 服務提供商、大學、數據中心等處獲得這些地址。

引用自:https://serverfault.com/questions/793571