Linux

核心 3.10 的 IPv6 鄰居發現/路由失敗

  • November 13, 2021

愚蠢的錯誤導致了這一切,請閱讀更新 5

介紹

我正在嘗試使用 IPv6 設置 Linux 路由器(LXC,3.10.0-123.el7.x86_64)。

提供商是 Hetzner,我有 2 個子網,一個 /56 和一個 /64。他們已經設置了到我的 LL 地址的路由,我的預設網關是 fe80::1。

我在以下位置啟用了 ipv6 和 ipv4 轉發sysctl.conf

net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

我將 IPTables 配置為接受所有內容。

我知道這ICMPv6是用於在 IPv6 中路由的主要實用程序 - 所以它不會被阻止;-)。我還添加了-A FORWARD -j ACCEPT.

我已將 /56 子網的第二個 (::2) ip 配置為 eth1,將 /64 的第二個 (::2) 配置為 eth0。

  • eth0 是上行介面
  • eth1 是區域網路介面

主要問題

來自 /56 的 ipv6 地址的內部客戶端無法 ping 外部世界,但數據包和響應被正確路由到我的路由器,它只是丟棄數據包而沒有任何提示。

例如ping6 ipv6.google.com導致超時。

但在路由器的上行鏈路上,我得到:

20:43:13.350932 IP6 client-ipv6-ip > fra07s64-in-x00.1e100.net: ICMP6, echo request, seq 1, length 64
20:43:13.355143 IP6 fra07s64-in-x00.1e100.net > client-ipv6-ip: ICMP6, echo reply, seq 1, length 64
20:43:14.350572 IP6 client-ipv6-ip > fra07s64-in-x00.1e100.net: ICMP6, echo request, seq 2, length 64
20:43:14.354609 IP6 fra07s64-in-x00.1e100.net > client-ipv6-ip: ICMP6, echo reply, seq 2, length 64
20:43:15.350630 IP6 client-ipv6-ip > fra07s64-in-x00.1e100.net: ICMP6, echo request, seq 3, length 64
20:43:15.355072 IP6 fra07s64-in-x00.1e100.net > client-ipv6-ip: ICMP6, echo reply, seq 3, length 64
20:43:16.350656 IP6 client-ipv6-ip > fra07s64-in-x00.1e100.net: ICMP6, echo request, seq 4, length 64
20:43:16.354748 IP6 fra07s64-in-x00.1e100.net > client-ipv6-ip: ICMP6, echo reply, seq 4, length 64

在客戶端上只有回應要求是可見的。

可能是什麼問題呢?是否有任何其他設置,以便我的路由器接受發送給它的任何內容?

到目前為止,我只使用 NAT,從未在我的 Linux 機器上使用過完整的路由。

感謝您的任何指點,我希望這只是一個簡單的 sysctl 參數來設置…

更新 1

我將 /56 子網替換為“subnet-2”,將 /64 替換為“subnet-1”。

ip -6 a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 
   inet6 ::1/128 scope host 
      valid_lft forever preferred_lft forever
61: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
   inet6 subnet-1::2/64 scope global 
      valid_lft forever preferred_lft forever
   inet6 fe80::216:2eff:fe01:1/64 scope link 
      valid_lft forever preferred_lft forever
63: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
   inet6 subnet-2::2/56 scope global 
      valid_lft forever preferred_lft forever
   inet6 fe80::216:3eff:fe01:1/64 scope link 
      valid_lft forever preferred_lft forever

ip -6 r:

unreachable ::/96 dev lo  metric 1024  error -101
unreachable ::ffff:0.0.0.0/96 dev lo  metric 1024  error -101
unreachable 2002:a00::/24 dev lo  metric 1024  error -101
unreachable 2002:7f00::/24 dev lo  metric 1024  error -101
unreachable 2002:a9fe::/32 dev lo  metric 1024  error -101
unreachable 2002:ac10::/28 dev lo  metric 1024  error -101
unreachable 2002:c0a8::/32 dev lo  metric 1024  error -101
unreachable 2002:e000::/19 dev lo  metric 1024  error -101
subnet-1::/64 dev eth0  proto kernel  metric 256 
subnet-2::/56 dev eth1  proto kernel  metric 256 
unreachable 3ffe:ffff::/32 dev lo  metric 1024  error -101
fe80::/64 dev eth0  proto kernel  metric 256 
fe80::/64 dev eth1  proto kernel  metric 256 
default via fe80::1 dev eth0  metric 1024 

系統是最新的,除了核心(例如它沒有載入),因為這需要重新啟動,而我沒有遇到目前的問題。但如果這是 3.10.0-123.13.2.el7 的已知問題,我可以重新啟動以將其升級到 3.10.0-229.14.1.el7。

更新 2

tcpdump -i eth0 ip6 

顯示傳入的數據包。

我添加了一個防火牆規則來破壞例如

*mangle
-A PREROUTING -j NFLOG

登錄到/var/log/messages,但那裡沒有記錄任何內容!

更新 3

   Bridge "br0"
       Port "router.eth0"
           Interface "router.eth0"
       Port "br0"
           Interface "br0"
               type: internal
       Port "eth0"
           Interface "eth0"
   Bridge "br1"
       Port "db01.eth0"
           Interface "db01.eth0"
       Port "mail01.eth0"
           Interface "mail01.eth0"
       Port "br1"
           Interface "br1"
               type: internal
       Port "team1"
           Interface "eth3"
           Interface "eth2"
       Port "router.eth1"
           Interface "router.eth1"

更新 4

我搞砸了,介面上的 MAC 地址錯誤(長話短說 - 現在已修復)。

所以現在數據包被接受並轉發,但響應沒有發送到預設網關:

路由器:

22:09:22.638405 IP6 ping_ip > client_ip: ICMP6, echo request, seq 243, length 64
22:09:22.754936 IP6 router-ll > ff02::1:ff00:1: ICMP6, neighbor solicitation, who has fe80::1, length 32
22:09:22.757001 IP6 2a01:4f8::a:b:10 > router-ll: ICMP6, neighbor advertisement, tgt is fe80::1, length 32
22:09:22.757044 IP6 router-ll > ff02::1:ff00:2: ICMP6, neighbor solicitation, who has router-ll, length 32
22:09:23.639651 IP6 ping_ip > client_ip: ICMP6, echo request, seq 244, length 64
22:09:23.756969 IP6 router-ll > ff02::1:ff00:1: ICMP6, neighbor solicitation, who has fe80::1, length 32
22:09:23.759007 IP6 router-ll > ff02::1:ff00:2: ICMP6, neighbor solicitation, who has router-ll, length 32
22:09:23.759240 IP6 2a01:4f8::a:b:10 > router-ll: ICMP6, neighbor advertisement, tgt is fe80::1, length 32
22:09:24.640677 IP6 ping_ip > client_ip: ICMP6, echo request, seq 245, length 64

客戶:

22:11:41.640978 IP6 ping_ip > client_ip: ICMP6, echo request, seq 382, length 64
22:11:41.640998 IP6 client_ip > ping_ip: ICMP6, echo reply, seq 382, length 64
22:11:42.642993 IP6 ping_ip > client_ip: ICMP6, echo request, seq 383, length 64
22:11:42.643013 IP6 client_ip > ping_ip: ICMP6, echo reply, seq 383, length 64

ip -6 neigh:

fe80::216:3eff:fe01:1 dev eth1 lladdr 00:16:3e:01:00:01 router STALE
subnet-2::1:1 dev eth0  FAILED
fe80::216:3eff:fe15:1 dev eth1 lladdr 00:16:3e:15:00:01 DELAY
fe80::216:3eff:fe15:c dev eth1 lladdr 00:16:3e:15:00:0c STALE
fe80::1 dev eth0  FAILED
subnet-2::1:1 dev eth1 lladdr 00:16:3e:15:00:01 REACHABLE
fe80::216:2eff:fe01:1 dev eth0  INCOMPLETE
subnet-2::1:12 dev eth1 lladdr 00:16:3e:15:00:0c STALE
subnet-1::2 dev eth0  FAILED

1:1 的失敗條目就在這裡,因為我很快就在 eth0 上有了那個地址來調試之前的 ping 問題……

更新 5

因此,在更改 MAC 地址時會發生這種情況,我沒有更改 LL 地址。我不知道這兩個地址是 100% 連結的。

主要問題是舊路由器死了,我從那裡複製了 LL 地址並沒有更改相應的 MAC 地址→它不起作用。

然後…將 LL 改回(這是錯誤)並更改了 MAC 地址(相隔幾個小時,分 2 個單獨的步驟)。

對於其他任何人,L2 MAC 和 IPv6 LL 地址需要對應,並且它們需要與路由器發送的內容相匹配。

要調試使用tcpdump -i eth0 ip6 -en,您可以查看 MAC 地址和 LL 地址,並將它們與您的介面進行比較,如果它們中的任何一個與在 Hetzner 配置為路由地址的地址不匹配,則無濟於事!

再說一次,對任何讀過這篇文章的人感到抱歉,我不知何故錯過了解釋它之前在不同的路由器上,我安裝了這個,因為最後一個死了。明顯的修復…

如果您在失去數據包時遇到奇怪的路由問題,請按照以下步驟操作:

ip l並記下 MAC 地址

tcpdump -en -i eth0 ip6(或相應的介面)並比較它們,如果它們匹配就很好

ip -6 a將連結本地地址(本地範圍)與您的 mac 地址進行比較(這裡有一個計算器:http ://ben.akrin.com/?p=1347 ,有幾個)

如果它仍然無法正常工作,我猜問題出在 iptables 上,請盡可能使用日誌記錄 :)

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