Configure bonded 802.3ad network using netplan on Ubuntu 18.04

20,500

After some digging, I discovered that Ubuntu 18.04 uses a utility called cloud-init to handle network configuration and initialization during the boot sequence. The file /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg and other .cfg files are used to reconfigure cloud-init settings. My config file settings are as follows:

network:
  version: 2
  ethernets:
    eports:
      match:
        name: eno*
      optional: true
  bonds:
    bond0:
      interfaces: [eports]
      addresses: [192.168.1.101/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
      parameters:
        mode: 802.3ad
        lacp-rate: fast
        mii-monitor-interval: 100

The optional: true parameter prevents the system from waiting for a valid network connection at boot time which will save you the hassle of waiting 2 minutes for your machine to boot. After updating the config file run the following command to update your configuration.

cloud-init clean -reboot

Alternatively running the following allows for some debug information without rebooting your machine; however, a reboot will be required to commit the changes during early boot stages.

cloud-init clean
cloud-init init
cloud-init status 
Share:
20,500

Related videos on Youtube

n8tlarsen
Author by

n8tlarsen

Updated on September 18, 2022

Comments

  • n8tlarsen
    n8tlarsen over 1 year

    I am running into some issues configuring netplan on Ubuntu 18.04 server to bond my four hardware ethernet ports named eno1, eno2, eno3, eno4 using the 802.3ad protocol. I've consulted the netplan man page and put together the following config file /etc/netplan/50-cloud-init.yaml:

    network:
      version: 2
      renderer: networkd
      ethernets:
        eports:
          match: 
            name: eno*
      bonds:
        bond0:
          interfaces: [eports]
          addresses: [192.168.1.101/24]
          gateway4: 192.168.1.1
          nameservers:
            addresses: [8.8.8.8, 8.8.4.4]          
          parameters:
            mode: 802.3ad            
            lacp-rate: fast            
            mii-monitor-interval: 100
    

    Upon running the command sudo netplan --debug apply I receive the following information:

    ** (generate:6473): DEBUG: 00:39:14.911: Processing input file //etc/netplan/50-cloud-init.yaml..
    ** (generate:6473): DEBUG: 00:39:14.911: starting new processing pass
    ** (generate:6473): DEBUG: 00:39:14.911: eports: setting default backend to 1
    ** (generate:6473): DEBUG: 00:39:14.911: bond0: setting default backend to 1
    ** (generate:6473): DEBUG: 00:39:14.912: Generating output files..
    ** (generate:6473): DEBUG: 00:39:14.912: NetworkManager: definition eports is not for us (backend 1)
    ** (generate:6473): DEBUG: 00:39:14.912: NetworkManager: definition bond0 is not for us (backend 1)
    DEBUG:netplan generated networkd configuration exists, restarting networkd
    DEBUG:no netplan generated NM configuration exists
    DEBUG:device eno2 operstate is up, not replugging
    DEBUG:netplan triggering .link rules for eno2
    DEBUG:device lo operstate is unknown, not replugging
    DEBUG:netplan triggering .link rules for lo
    DEBUG:replug eno3: unbinding 0000:03:00.0 from /sys/bus/pci/drivers/igb
    DEBUG:replug eno3: rebinding 0000:03:00.0 to /sys/bus/pci/drivers/igb
    DEBUG:replug eno1: unbinding 0000:01:00.0 from /sys/bus/pci/drivers/igb
    DEBUG:replug eno1: rebinding 0000:01:00.0 to /sys/bus/pci/drivers/igb
    DEBUG:Cannot replug bond0: cannot read link /sys/class/net/bond0/device: [Errno 2] No such file or directory: '/sys/class/net/bond0/device'
    DEBUG:netplan triggering .link rules for bond0
    DEBUG:replug eno4: unbinding 0000:04:00.0 from /sys/bus/pci/drivers/igb
    DEBUG:replug eno4: rebinding 0000:04:00.0 to /sys/bus/pci/drivers/igb
    

    I'm not sure what to make of the statement

    Cannot replug bond0: cannot read link /sys/class/net/bond0/device: [Errno 2] No such file or directory: '/sys/class/net/bond0/device'
    

    since the directory /sys/class/net/bond0 was generated by the netplan apply command.

    I checked my ifconfig output and my network devices seem to be configured correctly with the exception that no address is set for bond0:

    bond0: flags=5123<UP,BROADCAST,MASTER,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 112768  bytes 7785014 (7.7 MB)
        RX errors 0  dropped 54  overruns 0  frame 0
        TX packets 18854  bytes 2337896 (2.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eno1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 290  bytes 19322 (19.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 55  bytes 6820 (6.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xdf400000-df47ffff  
    
    eno2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 73991  bytes 29824155 (29.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20848  bytes 2110417 (2.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xdf300000-df37ffff  
    
    eno3: flags=6147<UP,BROADCAST,SLAVE,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  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
        device memory 0xdf200000-df27ffff  
    
    eno4: flags=6147<UP,BROADCAST,SLAVE,MULTICAST>  mtu 1500
        ether XX:XX:XX:XX:XX:XX  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
        device memory 0xdf100000-df17ffff  
    
    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 2923  bytes 184477 (184.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2923  bytes 184477 (184.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    The ether XX:XX:XX:XX:XX:XX statements are in place of each interfaces's mac address. In the original output, all addresses are the same.

    What am I missing to successfully configure my system?

    • Mathieu Trudel-Lapierre
      Mathieu Trudel-Lapierre about 6 years
      The configuration looks fine. What is in /run/systemd/network/* ? What does the 'networkctl' command report? I wonder if things might be confused by all the MACs being the same for the underlying interfaces, usually there is at least a small difference (the last character, maybe).
  • Seamus
    Seamus about 4 years
    This answer may have been true when it was posted, but in 2020 it is not. There is no eports parameter in netplan. After spending the last hour researching this, I've come to wonder if this entire netplan scheme is just not ready for prime time? Anyone reading this comment should also read this