Azure

azure linux沒有預設的ipv6路由

  • September 6, 2021

環境

  • 虛擬機:Linux Debian 10.10
  • 具有 ipv4 和 ipv6 地址空間和子網的虛擬網路
  • 公共 ipv4 地址和公共 ipv6 地址(標準 SKU)
  • 虛擬機網卡關聯公網ipv4和公網ipv6地址
  • VM NIC 分配了私有 ipv4 和 ipv6 地址(檢查ip address

網路安全組:

在此處輸入圖像描述

網路網卡 有效路由

在此處輸入圖像描述

問題

無法連接http://ipv6.google.com

# curl -v http://ipv6.google.com
*   Trying 2404:6800:4005:812::200e...
* TCP_NODELAY set
* Immediate connect fail for 2404:6800:4005:812::200e: Network is unreachable
* Closing connection 0
curl: (7) Couldn't connect to server

沒有 ipv6 預設路由

# ip -6 r
::1 dev lo proto kernel metric 256 pref medium
fd00::/80 dev docker0 metric 1024 linkdown pref medium
fd00:4244:7016::4 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev docker0 proto kernel metric 256 linkdown pref medium
fe80::/64 dev br-a3568bc4adc5 proto kernel metric 256 pref medium
fe80::/64 dev veth907e563 proto kernel metric 256 pref medium
fe80::/64 dev vethdf50b7b proto kernel metric 256 pref medium
fe80::/64 dev veth1322b71 proto kernel metric 256 pref medium
fe80::/64 dev veth6d1b4d6 proto kernel metric 256 pref medium
fe80::/64 dev vethca17875 proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium

ipv6 路由器通告中沒有預設路由

路由器通告只包含前綴長度

# tcpdump -i eth0 -vv icmp6
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
00:51:28.053407 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::1234:5678:9abc > ip6-allnodes: [icmp6 sum ok] ICMP6, router advertisement, length 56
       hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 9000s, reachable time 0ms, retrans timer 0ms
         source link-address option (1), length 8 (1): 12:34:56:78:9a:bc
           0x0000:  1234 5678 9abc
         prefix info option (3), length 32 (4): fd00:4244:7016::/64, Flags [onlink], valid time infinity, pref. time infinity
           0x0000:  4080 ffff ffff ffff ffff 0000 0000 fd00
           0x0010:  4244 7016 0000 0000 0000 0000 0000

IPV6 地址

# ip -6 address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
   inet6 fd00:4244:7016::4/128 scope global
      valid_lft forever preferred_lft forever
   inet6 fe80::20d:3aff:fe82:b7d3/64 scope link
      valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 state DOWN
   inet6 fe80::1/64 scope link tentative
      valid_lft forever preferred_lft forever
4: br-a3568bc4adc5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::42:5bff:fe7d:1e0d/64 scope link
      valid_lft forever preferred_lft forever
16: veth907e563@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::44da:baff:fef3:c54d/64 scope link
      valid_lft forever preferred_lft forever
18: vethdf50b7b@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::5c5d:93ff:fead:8190/64 scope link
      valid_lft forever preferred_lft forever
20: veth1322b71@if19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::f4a1:ceff:fe3e:55f4/64 scope link
      valid_lft forever preferred_lft forever
22: veth6d1b4d6@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::60de:73ff:fe59:74ec/64 scope link
      valid_lft forever preferred_lft forever
24: vethca17875@if23: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
   inet6 fe80::f47a:a6ff:febf:a444/64 scope link
      valid_lft forever preferred_lft forever

我解決了這個問題。預設情況下啟用 ipv6 轉發並accept_ra設置為 1 忽略路由器通告。添加以下內容以/etc/sysctl.conf關閉 ipv6 轉發:

net.ipv6.conf.all.forwarding=0

更新

ipv6 轉發由docker ipv6 feature啟用。accept_ra=2因此,在啟用 ipv6 的情況下為 docker設置介面。

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