使用 Ubuntu 22.04 在 EC2 上配置辅助接口

使用 Ubuntu 22.04 在 EC2 上配置辅助接口

我已经启动了一个具有操作系统 Ubuntu 22.04 的 EC2 实例,它具有主接口 ens5,并附加了辅助接口 ens6。

这是输出配置文件

root@ip-172-31-7-213:/home/ubuntu# ifconfig -a
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.7.213  netmask 255.255.240.0  broadcast 172.31.15.255
        inet6 fe80::879:bdff:fe2d:2a5e  prefixlen 64  scopeid 0x20<link>
        ether 0a:79:bd:2d:2a:5e  txqueuelen 1000  (Ethernet)
        RX packets 19401  bytes 27879459 (27.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4460  bytes 419785 (419.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens6: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 0a:12:bc:bf:55:7c  txqueuelen 1000  (Ethernet)
        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 0  dropped 0 overruns 0  carrier 0  collisions 0

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 142  bytes 15766 (15.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 142  bytes 15766 (15.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

输出/etc/netplan/50-cloud-init.yaml

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens5:
            dhcp4: true
            dhcp6: false
            match:
                macaddress: 0a:79:bd:2d:2a:5e
            set-name: ens5
    version: 2

我尝试对上述配置进行如下更改:

network:
  version: 2
  ethernets:
    ens5:
      dhcp4: true
      dhcp6: false
      match:
        macaddress: 0a:79:bd:2d:2a:5e
      set-name: ens5
    ens6:
      dhcp4: true
      dhcp6: false
      match:
        macaddress: 0a:12:bc:bf:55:7c
      set-name: ens6

但我丢失了 SSH 连接,之后重启后它就再也没用了。有人能帮我配置一下吗?TIA

相关内容