Introduction

Ubuntu 1804 server uses netplan for network management. This post will cover how to create a bridge interface with netplan in order to have multiple virtual machines share the same physical interface.

Create the following /etc/netplan/01-netcfg.yaml file in order to configure the bridge interface.

cmd

sudo tee /etc/netplan/01-netcfg.yaml > /dev/null << "EOF"
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces: [eno1]
      dhcp4: no
      dhcp6: no
      addresses: [10.0.0.10/24]
      gateway4: 10.0.0.1
      nameservers:
        addresses: [10.0.0.5]
      parameters:
        stp: false
        forward-delay: 0
EOF
          

There are a couple of things I would like to highlight.

  • networkd - The network management daemon
  • eno1 - The name of the physical interface
  • br0 - The name of the bridge interface

Rename the default cloud-init network file. This will prevent cloud-init from attempting to configure the network on reboot.

cmd

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

Finally disable network portion of the cloud-init config by creating the the below /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg file.

cmd

sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg > /dev/null << "EOF"
network: {config: disabled}
EOF
          

Summary

This post covered how to create a bridge interface using netplan on Ubuntu 1804 server edition. This allows you to have multiple VMs share a single physical interface.

linux ubuntu networking