将IP6链路本地地址添加到gretap接口

将IP6链路本地地址添加到gretap接口

我创建了一个正在运行的 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

有人可以指出这里到底什么是无效的吗?有什么方法可以获取更多信息吗?

答案1

RFC 2460

  1. 数据包大小问题

    IPv6 要求互联网中的每个链接都有一个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。

相关内容