如何在 ubuntu 18.04 上绑定接口?

如何在 ubuntu 18.04 上绑定接口?

我为我的家庭服务器安装了一个额外的 4x1gb NIC,我想为该 NIC 使用链路聚合。当然,其中一个链接坏了(便宜的 ebay,或者几年前在 ali-express 买的)。所以我只有三个端口。最好将 4 个板载 nic 绑定起来……

但无论如何。eno1主板上有一个我仍然想使用的 IPMI 连接。我想绑定和enp2s0f1。看来我可以做到这一点。enp2s0f2enp2s0f3但当我拔掉电缆时,出于某种原因eno1我无法访问bond0。我遵循了多个指南,可能造成了一些损害,但我试图撤消所有更改并只遵循一个指南。这个 askubuntu 线程是我最终得到的。但我也一直在捣鼓/etc/network/interfaces(这过时了吗?)。

这是我的 /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.
# To disablecloud-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:
  version: 2
  ethernets:
    enp2s0f1:
      addresses: []
      dhcp4: false
      dhcp6: false
    enp2s0f2:
      addresses: []
      dhcp4: false
      dhcp6: false
    enp2s0f3:
      addresses: []
      dhcp4: false
      dhcp6: false
  bonds:
    bond0:
      addresses: [192.168.1.254/24]
      gateway4: 192.168.1.1
      interfaces: [enp2s0f1, enp2s0f2, enp2s0f3]
      parameters:
        lacp-rate: fast
        mode: 802.3ad
        transmit-hash-policy: layer2

所以我想bond0成为“主”网络,但保留eno0IPMI(也许是 ssh 的备份 IP?)

编辑:

$ cat /etc/network/interfaces

# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#     sudo apt intall ifupdown

$ sudo lshw -C network

 *-network:0 UNCLAIMED
       description: Ethernet controller
       product: I350 Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:02:00.0
       version: 01
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress cap_list
       configuration: latency=0
       resources: memory:80000000-800fffff memory:80480000-80483fff memory:80400000-8047ffff memory:80484000-804a3fff memory:804a4000-804c3fff
  *-network:1 DISABLED
       description: Ethernet interface
       product: I350 Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 0.1
       bus info: pci@0000:02:00.1
       logical name: enp2s0f1
       version: 01
       serial: a0:36:9f:03:cb:b5
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.4.0-k firmware=0.93, 0x800005fd latency=0 link=no multicast=yes port=twisted pair
       resources: irq:17 memory:80100000-801fffff memory:804c4000-804c7fff memory:804c8000-804e7fff memory:804e8000-80507fff
  *-network:2 DISABLED
       description: Ethernet interface
       product: I350 Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 0.2
       bus info: pci@0000:02:00.2
       logical name: enp2s0f2
       version: 01
       serial: a0:36:9f:03:cb:b6
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.4.0-k firmware=0.93, 0x800005fd latency=0 link=no multicast=yes port=twisted pair
       resources: irq:18 memory:80200000-802fffff memory:80508000-8050bfff memory:8050c000-8052bfff memory:8052c000-8054bfff
  *-network:3 DISABLED
       description: Ethernet interface
       product: I350 Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 0.3
       bus info: pci@0000:02:00.3
       logical name: enp2s0f3
       version: 01
       serial: a0:36:9f:03:cb:b7
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.4.0-k firmware=0.93, 0x800005fd latency=0 link=no multicast=yes port=twisted pair
       resources: irq:19 memory:80300000-803fffff memory:8054c000-8054ffff memory:80550000-8056ffff memory:80570000-8058ffff
  *-network:0
       description: Ethernet interface
       product: Ethernet Connection X553 1GbE
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:06:00.0
       logical name: eno1
       version: 11
       serial: ac:1f:6b:45:e2:b8
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list rom ethernet physical tp 10bt-fd 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=ixgbe driverversion=5.1.0-k duplex=full firmware=0x80000877 ip=192.168.1.236 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:16 memory:ddc00000-dddfffff memory:dde04000-dde07fff memory:80600000-8067ffff memory:80700000-807fffff memory:80800000-808fffff
  *-network:1 DISABLED
       description: Ethernet interface
       product: Ethernet Connection X553 1GbE
       vendor: Intel Corporation
       physical id: 0.1
       bus info: pci@0000:06:00.1
       logical name: eno2
       version: 11
       serial: ac:1f:6b:45:e2:b9
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list rom ethernet physical tp 10bt-fd 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=ixgbe driverversion=5.1.0-k firmware=0x80000877 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:17 memory:dda00000-ddbfffff memory:dde00000-dde03fff memory:80680000-806fffff memory:80900000-809fffff memory:80a00000-80afffff
  *-network:0 DISABLED
       description: Ethernet interface
       product: Ethernet Connection X553 1GbE
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:07:00.0
       logical name: eno3
       version: 11
       serial: ac:1f:6b:45:e2:ba
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list rom ethernet physical tp 10bt-fd 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=ixgbe driverversion=5.1.0-k firmware=0x8000087c latency=0 link=no multicast=yes port=twisted pair
       resources: irq:17 memory:dd600000-dd7fffff memory:dd804000-dd807fff memory:80b00000-80b7ffff memory:80c00000-80cfffff memory:80d00000-80dfffff
  *-network:1 DISABLED
       description: Ethernet interface
       product: Ethernet Connection X553 1GbE
       vendor: Intel Corporation
       physical id: 0.1
       bus info: pci@0000:07:00.1
       logical name: eno4
       version: 11
       serial: ac:1f:6b:45:e2:bb
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list rom ethernet physical tp 10bt-fd 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=ixgbe driverversion=5.1.0-k firmware=0x8000087c latency=0 link=no multicast=yes port=twisted pair
       resources: irq:18 memory:dd400000-dd5fffff memory:dd800000-dd803fff memory:80b80000-80bfffff memory:80e00000-80efffff memory:80f00000-80ffffff

参考

https://www.cyberciti.biz/faq/ubuntu-setup-a-bonding-device-and-enslave-two-real-ethernet-devices/

https://www.snel.com/support/how-to-set-up-lacp-bonding-on-ubuntu-18-04-with-netplan/

https://gist.github.com/PhilipSchmid/54e17f53c15e3bd2c922ec6ff9ee434f

https://help.ubuntu.com/community/UbuntuBonding

相关内容