Netplan – How to Create a Bond Interface in Ubuntu 18.04

netplannic

I'm trying to reinstall an Ubuntu server to 18.04.

I discovered that 18.04 uses Netplan, and I'm having trouble creating a bond interface using this.

Updated configuration:

############# BOND - VLAN ##################
network:
    version: 2
    renderer: networkd
    ethernets:
        switchports:
            match: {name: "ens*"}
    bonds:
        bond0:
            interfaces: [switchports]
            parameters:
                mode: balance-alb
    vlans:
        inet:
            id: 50
            link: bond0
            addresses: [X.X.X.X/24]
            gateway4: X.X.X.252
            dhcp4: no
            nameservers:
                addresses: [X.X.X.33]

It seems that I shouldn't have 2 match statements and ens* in a single statement did it – I'll clean this up when I get it to work..

I have installed ifenslave & bridge-utils as someone suggested this, still nothing.

Also I've enabled the bonding module in /etc/modules.

My original issue was that the interface was in UP state, but I could only ping the interface itself, not anything else.

I couldn't get this to work, so I ended up renaming the /etc/netplan/<name>.yaml file and installing ifupdown.

If anyone has a clue as to why this didn't work, I'll be happy to know 🙂

Best Answer

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!