Linux

將 IP6 連結本地地址添加到 gretap 介面

  • December 28, 2019

我創建了一個正在工作的 GRETAP 界面:

$ ip link show t104016114 
15: t104016114@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1242 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff
$ ip address list t104016114
15: t104016114@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1242 qdisc fq_codel state UNKNOWN group default qlen 1000
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff
   inet 10.40.16.226/14 brd 10.43.255.255 scope global dynamic t104016114
      valid_lft 2836sec preferred_lft 2836sec

我希望它有一個 IP6 連結本地地址,但這是我卡住的地方:

$ ipv6calc --in prefix+mac fe80:: 06:ef:75:cf:2c:b6
No action type specified, try autodetection...found type: prefixmac2ipv6
fe80::4ef:75ff:fecf:2cb6
$ sudo ip addr add dev t104016114 scope link noprefixroute fe80::4ef:75ff:fecf:2cb6/64
RTNETLINK answers: Invalid argument

有人可以指出這裡到底是什麼無效的嗎?有什麼方法可以獲取更多資訊嗎?

根據RFC 2460

  1. 數據包大小問題

IPv6 要求 Internet 中的每個連結的MTU 為 1280

字節或更高。在任何不能一次性傳送 1280 字節數據包的鏈路上,必須 在低於 IPv6 的層提供

特定於鏈路的分段和重組。

由於某些可能與您打算進行的隧道(或多層隧道)有關的原因,您的介面 MTU 低於 1280。在這種情況下,Linux 實現將不認為該介面適用於 IPv6。IPv6 被禁用,這可以顯示我的測試:

# ip netns add testbed

第一學期:

# ip -n testbed monitor 

第二學期:

# ip -n testbed link add t104016114 address 06:ef:75:cf:2c:b6 type gretap remote 10.100.0.2 local 10.100.0.1

第一學期:

   inet t104016114 forwarding on rp_filter strict mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off 
inet6 t104016114 forwarding off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off 
5: t104016114@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default 
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff
5: t104016114@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default 
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff

請注意,預設情況下,選定的 MTU 為 1462。

第二學期:

# ip -n testbed link set t104016114 up

第一學期:

ff00::/8 dev t104016114 table local metric 256 pref medium
fe80::/64 dev t104016114 proto kernel metric 256 pref medium
5: t104016114    inet6 fe80::4ef:75ff:fecf:2cb6/64 scope link 
      valid_lft forever preferred_lft forever
local fe80::4ef:75ff:fecf:2cb6 dev t104016114 table local proto kernel metric 0 pref medium

第二學期:

# ip -n testbed link set t104016114 mtu 1242

第一學期:

5: t104016114@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1242 qdisc pfifo_fast state UNKNOWN group default 
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff
Deleted fe80::/64 dev t104016114 proto kernel metric 256 pref medium
Deleted local fe80::4ef:75ff:fecf:2cb6 dev t104016114 table local proto kernel metric 0 pref medium
Deleted ff00::/8 dev t104016114 table local metric 256 pref medium
Deleted ff02::2 dev t104016114 lladdr 33:33:00:00:00:02 NOARP
Deleted ff02::1:ffcf:2cb6 dev t104016114 lladdr 33:33:ff:cf:2c:b6 NOARP
Deleted ff02::16 dev t104016114 lladdr 33:33:00:00:00:16 NOARP
Deleted 5: t104016114    inet6 fe80::4ef:75ff:fecf:2cb6/64 scope link 
      valid_lft forever preferred_lft forever
Deleted inet6 t104016114 

第二學期:

# ip -n testbed addr add dev t104016114 scope link noprefixroute fe80::4ef:75ff:fecf:2cb6/64
RTNETLINK answers: Invalid argument

第二學期:

# ip -n testbed link set t104016114 mtu 1462

第一學期:

5: t104016114@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1462 qdisc pfifo_fast state UNKNOWN group default 
   link/ether 06:ef:75:cf:2c:b6 brd ff:ff:ff:ff:ff:ff
inet6 t104016114 forwarding off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off 
ff00::/8 dev t104016114 table local metric 256 pref medium
fe80::/64 dev t104016114 proto kernel metric 256 pref medium
5: t104016114    inet6 fe80::4ef:75ff:fecf:2cb6/64 scope link 
      valid_lft forever preferred_lft forever
local fe80::4ef:75ff:fecf:2cb6 dev t104016114 table local proto kernel metric 0 pref mediump-sysctl.txt?h=v5.3#n1739

對於最小值,正如預期的那樣,選擇 1279 將再次禁用 IPv6,使用 mtu 1280 將允許返回 IPv6。

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