Linux

為什麼我的綁定有兩個 ipv6 地址?

  • September 30, 2021

你可以在下面看到,bond 有兩個 ipv6 地址,2603:8080:4540:7cfb::13fc 和 2603:8080:4540:7cfb:4866:4bff:fe44:a988。這讓我認為 systemd-networkd 無法將綁定視為單個介面。

root@gentooserver /etc/systemd/network # networkctl
IDX LINK  TYPE      OPERATIONAL SETUP     
 1 lo    loopback  carrier     unmanaged
 2 eno1  ether     enslaved    configured
 3 eno2  ether     enslaved    configured
 4 bond1 bond      routable    configured
 5 wg0   wireguard routable    unmanaged

5 links listed.

root@gentooserver /etc/systemd/network # networkctl status bond1
● 4: bond1                                                                               
                    Link File: /lib/systemd/network/99-default.link
                 Network File: /etc/systemd/network/master.network
                         Type: bond
                        State: routable (configured)
                 Online state: online                                                   
                       Driver: bonding
                   HW Address: 4a:66:4b:44:a9:88
                          MTU: 1500 (min: 68, max: 65535)
                        QDisc: noqueue
 IPv6 Address Generation Mode: eui64
                         Mode: 802.3ad
                       Miimon: 10s
                      Updelay: 20s
                    Downdelay: 1min 20s
         Queue Length (Tx/Rx): 16/16
             Auto negotiation: no
                        Speed: 1Gbps
                       Duplex: full
                      Address: 10.0.0.46 (DHCP4 via 10.0.0.1)
                               2603:8080:4540:7cfb::13fc
                               2603:8080:4540:7cfb:4866:4bff:fe44:a988
                               fe80::4866:4bff:fe44:a988
                      Gateway: 10.0.0.1
                               fe80::96de:80ff:fea8:8096 (GIGA-BYTE TECHNOLOGY CO.,LTD.)
                               fe80::a263:91ff:fe7c:32a2 (NETGEAR)
                          DNS: 10.0.0.1
                               2603:8080:4540:7cfb:96de:80ff:fea8:8096
               Search Domains: dehnel.info
             Carrier Bound To: eno1
                               eno2
            Activation Policy: bound
          Required For Online: yes
              DHCP4 Client ID: IAID:0x8db4800/DUID
            DHCP6 Client IAID: 0x8db4800
            DHCP6 Client DUID: DUID-EN/Vendor:0000ab11abc83a896377c51f0000

Sep 29 17:35:35 gentooserver systemd-networkd[2235623]: bond1: Link UP
Sep 29 17:35:35 gentooserver systemd-networkd[2235623]: bond1: Gained carrier
Sep 29 17:35:35 gentooserver systemd-networkd[2235623]: bond1: Lost carrier
Sep 29 17:35:35 gentooserver systemd-networkd[2235623]: bond1: DHCPv6 lease lost
Sep 29 17:35:35 gentooserver systemd-networkd[2235623]: bond1: Link DOWN
Sep 29 17:35:38 gentooserver systemd-networkd[2235623]: bond1: Link UP
Sep 29 17:35:38 gentooserver systemd-networkd[2235623]: bond1: Gained carrier
Sep 29 17:35:40 gentooserver systemd-networkd[2235623]: bond1: Gained IPv6LL
Sep 29 17:35:42 gentooserver systemd-networkd[2235623]: bond1: DHCPv4 address 10.0.0.46/24 via 10.0.0.1
Sep 29 17:35:43 gentooserver systemd-networkd[2235623]: bond1: DHCPv6 address 2603:8080:4540:7cfb::13fc/128 (valid for 2h, preferred for 1h 15min)

root@gentooserver /etc/systemd/network # tail *
==> bond1.netdev <==
Name=bond1
Kind=bond

[Bond]
Mode=802.3ad
MIIMonitorSec=1s
LACPTransmitRate=fast
TransmitHashPolicy=layer2
UpDelaySec=2s
DownDelaySec=8s

==> eno1.network <==
[Match]
Name=eno1

[Network]
Bond=bond1

==> eno2.network <==
[Match]
Name=eno2

[Network]
Bond=bond1

==> master.network <==
IPv6AcceptRA=yes

[Link]
Multicast=yes

[DHCPv4]
UseDomains=true

[IPv6AcceptRA]
UseDomains=yes

root@gentooserver /etc/systemd/network # ifconfig
bond1: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
       inet 10.0.0.46  netmask 255.255.255.0  broadcast 10.0.0.255
       inet6 fe80::4866:4bff:fe44:a988  prefixlen 64  scopeid 0x20<link>
       inet6 2603:8080:4540:7cfb::13fc  prefixlen 128  scopeid 0x0<global>
       inet6 2603:8080:4540:7cfb:4866:4bff:fe44:a988  prefixlen 64  scopeid 0x0<global>
       ether 4a:66:4b:44:a9:88  txqueuelen 1000  (Ethernet)
       RX packets 179330571  bytes 26132404875 (24.3 GiB)
       RX errors 0  dropped 914092  overruns 0  frame 0
       TX packets 1543646148  bytes 2313271455798 (2.1 TiB)
       TX errors 0  dropped 5 overruns 0  carrier 0  collisions 0

eno1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
       ether 4a:66:4b:44:a9:88  txqueuelen 1000  (Ethernet)
       RX packets 2371371  bytes 200785874 (191.4 MiB)
       RX errors 0  dropped 911837  overruns 0  frame 0
       TX packets 60668  bytes 7644831 (7.2 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
       device memory 0xfae00000-fae7ffff  

eno2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
       ether 4a:66:4b:44:a9:88  txqueuelen 1000  (Ethernet)
       RX packets 176959198  bytes 25931618869 (24.1 GiB)
       RX errors 0  dropped 869  overruns 0  frame 0
       TX packets 1543585480  bytes 2313263810967 (2.1 TiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
       device memory 0xfad00000-fad7ffff  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
       inet 127.0.0.1  netmask 255.0.0.0
       inet6 ::1  prefixlen 128  scopeid 0x10<host>
       loop  txqueuelen 1000  (Local Loopback)
       RX packets 3334928  bytes 580238437 (553.3 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 3334928  bytes 580238437 (553.3 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wg0: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1420
       inet 192.168.2.1  netmask 255.255.255.0  destination 192.168.2.1
       inet6 fd86:ea04:1111::1  prefixlen 64  scopeid 0x0<global>
       unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
       RX packets 0  bytes 0 (0.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 0  bytes 0 (0.0 B)
       TX errors 18363  dropped 0 overruns 0  carrier 0  collisions 0

ip具有相同的MAC地址,這讓我認為綁定正在工作:

ip -6 neigh show | grep 2603:8080:4540:7cfb::13fc
2603:8080:4540:7cfb::13fc dev wlp170s0 lladdr 4a:66:4b:44:a9:88 router REACHABLE
ip -6 neigh show | grep 2603:8080:4540:7cfb:4866:4bff:fe44:a988
2603:8080:4540:7cfb:4866:4bff:fe44:a988 dev wlp170s0 lladdr 4a:66:4b:44:a9:88 router REACHABLE

您的 IPv6 前綴長度為 64,因此可以使用 SLAAC 進行自主地址配置。顯然,您的 IPv6 路由器廣告允許自主配置和使用 DHCPv6。

您可能想要執行rdisc6 -1 bond1以查看系統收到的路由器通告的內容。輸出可能包括Autonomous address conf.: Yes(即啟用 SLAAC 地址配置)和Stateful address conf. : Yes(啟用 DHCPv6 地址配置)之類的行。

這將導致為每個介面自動配置兩個 IPv6 地址 - 在這種情況下包括綁定。它是 IPv6 的有效配置,儘管可能不是您所期望的。

2603:8080:4540:7cfb:4866:4bff:fe44:a988似乎是從 MAC 地址和路由器通告的前綴生成的 EUI64 樣式地址。它可以通過 …:xSxx:xxff:fexx:xxxx格式辨識。這些x數字來自 MAC 地址的相應數字,而 S 數字的第二個最低有效位反轉。

2603:8080:4540:7cfb::13fc然後必須是 DHCPv6 分配的地址。

引用自:https://unix.stackexchange.com/questions/671183