桥接 Amazon EC2 Netplan (20.04)

桥接 Amazon EC2 Netplan (20.04)

我一直在尝试使用 netplan 在我的 EC2 实例 (Ubuntu 20.04) 上创建网桥,但我一直无法访问我的机器。目前正在尝试禁用 ENA,但不确定我是否只是忽略了一些显而易见的东西。这似乎类似于这个问题

我的“库存”配置如下:

network:
    ethernets:
        ens5:
            dhcp4: true
            dhcp6: false
            match:
                macaddress: **:**:**:**:**:**
            set-name: ens5
    version: 2

带有ifconfigip a返回:

ubuntu@ip-172-31-45-47:~$ ifconfig
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.45.47  netmask 255.255.240.0  broadcast 172.31.47.255
        inet6 fe80::860:82ff:fef8:c11c  prefixlen 64  scopeid 0x20<link>
        ether <same as macaddress>  txqueuelen 1000  (Ethernet)
        RX packets 48418  bytes 64806497 (64.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9470  bytes 989568 (989.5 KB)
        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 360  bytes 32234 (32.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 360  bytes 32234 (32.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ubuntu@ip-172-31-45-47:~$ 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 0a:60:82:f8:c1:1c brd ff:ff:ff:ff:ff:ff
    inet 172.31.45.47/20 brd 172.31.47.255 scope global dynamic ens5
       valid_lft 3104sec preferred_lft 3104sec
    inet6 fe80::860:82ff:fef8:c11c/64 scope link
       valid_lft forever preferred_lft forever

我尝试通过添加br0和复制 macaddress来实现桥接就像他们在这里所做的那样,但之后无法重新连接到 EC2 实例。

我都试过了

network:
    ethernets:
        ens5:
            dhcp4: false
            dhcp6: false
            match:
                macaddress: **:**:**:**:**:**
            set-name: ens5
    version: 2
    bridges:
        br0:
            dhcp4: true
            macaddress: **:**:**:**:**:**
            interfaces: [ens5]

就像在 netplan.io/examples 中一样,用于桥接和用于解决 AWS dhcp 服务器的问题,并且dhcp完全删除这些行,因为很明显我不知道自己在做什么。

非常感谢任何建议,因为我根本没有太多配置网络的经验。谢谢!

答案1

network:
  version: 2
  renderer: networkd
  ethernets:
    ens5:
      match:
        macaddress: 0a:60:82:f8:c1:1c
      set-name: ens5
  bridges:
    br0:
      dhcp4: true
      macaddress: 0a:60:82:f8:c1:1c
      interfaces:
        - ens5

sudo netplan --debug generate

sudo netplan apply

reboot

相关内容