通过 Netplan 配置 GRE (headless/aws)

通过 Netplan 配置 GRE (headless/aws)

如何将以下内容转换为以 networkd 为渲染器的 Netplan yaml 文件?

在命令行上,这些命令起作用并构建 MTU 为 1476 的 GRE 隧道。

ip tunnel add gre1 mode gre remote [x.x.x.x] local [y.y.y.y] ttl 255
ip link set gre1 up
ip addr add [z.z.z.z]/30 dev gre1

其中 [xxxx] 是远程 GRE 端点,[yyyy] 是 GRE 端点的私有 IP,[zzzz] 是分配给本地 GRE 接口的地址。

尝试使用以下 yaml 片段,隧道已定义但 MTU 被“忽略”并且设置了 LAN i/f MTU-24。

    tunnels:
        gre1:
            mode: gre
            local: [y.y.y.y]
            remote: [x.x.x.x]
            mtu: 1476
            addresses:
                - [z.z.z.z]/30

各种命令的输出:

# systemctl status systemd-networkd | grep gre1
Sep 16 11:49:40 ip-y-y-y-y systemd-networkd[1283]: gre1: Cannot enable IPv6 for interface gre1: No such file or directory
Sep 16 11:49:40 ip-y-y-y-y systemd-networkd[1283]: gre1: Could not bring up interface: Address family not supported by protocol

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 16:74:7e:e0:07:46 brd ff:ff:ff:ff:ff:ff
    inet [y.y.y.y]/24 brd [y.y.y.255] scope global dynamic ens5
       valid_lft 2631sec preferred_lft 2631sec
    inet6 fe80::1474:7eff:fee0:746/64 scope link
       valid_lft forever preferred_lft forever
3: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1000
    link/gre 0.0.0.0 brd 0.0.0.0
4: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
5: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
6: gre1@NONE: <POINTOPOINT,NOARP> mtu 8977 qdisc noop state DOWN group default qlen 1000
    link/gre [y.y.y.y] peer [x.x.x.x]
    inet [z.z.z.z]/30 brd [z.z.z.255] scope global gre1
       valid_lft forever preferred_lft forever

答案1

:embarrassed: 问题中的 yaml 片段在系统重启后生效,仅运行“netplan apply”是不够的。

相关内容