Netplan 干扰 IP 分配?? Ubuntu 18.10

Netplan 干扰 IP 分配?? Ubuntu 18.10

我有一个简单的 Ubuntu 测试平台,但遇到了一个非常不寻常的问题。出于某种原因,我的 IP 地址似乎在接口之间发生变化,而无需用户进行任何干预,我无法解释。

这是我得到的:一台装有 Ubuntu 18.10 Server(Cosmic?)的机器,带有一个通过 DHCP 静态保留映射到 IP 172.16.222.63 的 1GB 接口和一个静态分配 IP 172.16.222.64(使用 ifconfig)的 10GB 接口。此服务器为空白,安装期间仅选择了 OpenSSH-Server。

它连接到 HP Procurve 2900-48G 交换机,该交换机出厂时已默认设置。没有配置或启用任何 VLAN,所有交换机端口都已默认设置。1GB 接口和 10GB 接口连接到此交换机,就像一个测试盒。

在测试箱中,我在一个终端窗口中开始 ping 172.16.222.63 (1G),在另一个终端窗口中开始 ping 172.16.222.64 (10G)。只有 1G 接口有响应。

如果我断开 1G 接口,10G 接口就会开始 ping。如果我重新连接 1G 接口,10G 接口就会停止 ping。

我检查了 iptables,没有规则,所有内容都设置为默认允许。Arp 表按预期显示了我的测试盒的 MAC 和默认网关。

周五,我在 Linux subreddit 上询问了这个问题,尽管症状略有不同。当两个接口都连接时,它们都会 ping 通。如果 1G 接口断开连接,10G 接口仍可 ping 通,但是几分钟后,1G IP 地址将开始在 10G 接口上响应!重新连接 1G 接口并断开 10G 接口会导致两个 IP 都移动到 1G 接口。

与同事讨论后,大家普遍认为是 netplan 造成了问题。还有人见过这种情况吗?有什么方法可以修复此问题,让 IP 地址“停留”在分配给它们的接口上?

这样做的原因是我将对 1G 和 10G 接口进行一些性能测试,我需要能够将数据发送到这两个接口。在目前的状态下,我无法保证我通过 IP 地址将数据发送到正确的接口。

谢谢你!

编辑:根据要求:

Netplan yaml 文件:

root@ubuntu:~# cat /etc/netplan/*.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0f0:
      dhcp4: yes

lshw 输出

root@ubuntu:~# lshw -C network
  *-network
       description: Ethernet interface
       product: MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s]
       vendor: Mellanox Technologies
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: enp3s0
       version: b0
       serial: 00:02:c9:56:1c:88
       size: 10Gbit/s
       capacity: 10Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm vpd msix pciexpress bus_master cap_list ethernet physical fibre 10000bt-fd
       configuration: autonegotiation=off broadcast=yes driver=mlx4_en driverversion=4.0-0 duplex=full firmware=2.9.1000 ip=172.16.222.64 latency=0 link=yes multicast=yes port=fibre speed=10Gbit/s
       resources: irq:16 memory:b9a00000-b9afffff memory:b8800000-b8ffffff
  *-network DISABLED
       description: Ethernet interface
       product: MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s]
       vendor: Mellanox Technologies
       physical id: 0
       bus info: pci@0000:04:00.0
       logical name: enp4s0
       version: b0
       serial: 00:02:c9:54:00:a2
       capacity: 10Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm vpd msix pciexpress bus_master cap_list ethernet physical fibre 10000bt-fd
       configuration: autonegotiation=off broadcast=yes driver=mlx4_en driverversion=4.0-0 firmware=2.9.1000 latency=0 link=no multicast=yes port=fibre
       resources: irq:17 memory:b9900000-b99fffff memory:b8000000-b87fffff
  *-network:0
       description: Ethernet interface
       product: 80003ES2LAN Gigabit Ethernet Controller (Copper)
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:05:00.0
       logical name: enp5s0f0
       version: 01
       serial: 00:15:17:45:f3:08
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k firmware=1.0-0 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:24 memory:b9820000-b983ffff memory:b9400000-b97fffff ioport:2020(size=32)
  *-network:1 DISABLED
       description: Ethernet interface
       product: 80003ES2LAN Gigabit Ethernet Controller (Copper)
       vendor: Intel Corporation
       physical id: 0.1
       bus info: pci@0000:05:00.1
       logical name: enp5s0f1
       version: 01
       serial: 00:15:17:45:f3:09
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k firmware=1.0-0 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:25 memory:b9800000-b981ffff memory:b9000000-b93fffff ioport:2000(size=32)

ifconfig 输出:

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.222.64  netmask 255.255.255.0  broadcast 172.16.222.255
        inet6 fe80::202:c9ff:fe56:1c88  prefixlen 64  scopeid 0x20<link>
        ether 00:02:c9:56:1c:88  txqueuelen 1000  (Ethernet)
        RX packets 1446  bytes 134815 (134.8 KB)
        RX errors 2  dropped 0  overruns 0  frame 2
        TX packets 1169  bytes 121183 (121.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp5s0f0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet6 fe80::215:17ff:fe45:f308  prefixlen 64  scopeid 0x20<link>
        ether 00:15:17:45:f3:08  txqueuelen 1000  (Ethernet)
        RX packets 875  bytes 87240 (87.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 421  bytes 48304 (48.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  memory 0xb9820000-b9840000

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 3312  bytes 235824 (235.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3312  bytes 235824 (235.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

尝试一些更像这个骨架.yaml 文件的东西...确保没有制表符或多余的空格...一些地址可能需要调整...

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses: 172.16.222.64/24
      gateway4: 172.16.222.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
    enp4s0:
      dhcp4: no
      dhcp6: no
    enp5s0f0:
      addresses: 172.16.222.63/24
      gateway4: 172.16.222.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
    enp5s0f1:
      dhcp4: no
      dhcp6: no

然后

sudo netplan --debug generate# 生成配置文件

sudo netplan apply# 激活新配置

reboot# 可能是可选的...重新启动计算机

相关内容