How can I create a bond interface in Ubuntu 18.04?

Solution 1:

I installed Ubuntu Server and surprising enough it asked me if I wanted to to setup bonding.

This is the yaml file that was setup:

Location: /etc/netplan/ 

File Name: 50-cloud-init.yaml

File Structure:

# 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:
   bonds:
       bond0:
           addresses: []
           interfaces:
           - enp5s4
           - enp5s9
           - enp64s0
           parameters:
               lacp-rate: fast
               mode: 802.3ad
               transmit-hash-policy: layer2
       ethernets:
           enp5s4:
               addresses: []
               dhcp4: false
               dhcp6: false
           enp5s9:
               addresses: []
               dhcp4: false
               dhcp6: false
           enp64s0:
               addresses: []
               dhcp4: false
               dhcp6: false
version: 2

I will update this as I learn more about the newer style of networking configuration in Ubuntu.

UPDATE

To change this to be static address do the following:

 sudo mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.old

!Note! Your default *.yaml file name may be different.

 sudo touch /etc/netplan/my-network-file.yaml

!Note! You can name your config file whatever you want just make sure it ends with .yaml

sudo nano /etc/netplan/my-network-file.yaml

In this file (my-network-file.yaml) copy from above and append the following changes:

network:
   bonds:
       bond0:
           addresses: [192.168.0.8/24]
           gateway4: 192.168.0.1
           nameservers:
              addresses: [8.8.8.8,8.8.4.4]
           interfaces:
           - enp5s4
           - enp5s9
           - enp64s0

Make sure you change the ip addresses to reflect your network. After this, I just rebooted the machine and my new network config was loaded and working.

You can alternatively use:

sudo netplan apply

This should apply the new config without a need for a reboot.

Side Note You may want to observe spacing and not use tabs as this may cause issues with your config file.

If you're unsure of your network interfaces you can do one of the following

lshw -class network 

or

ip link show

Hope this helps!