apt get life

Life around technology

  • Technology
    • Guides
    • Linux
    • Development
      • Laravel
    • Misc
    • Raspberry Pi
  • Writing
  • Crafts
    • Crochet
    • Model Making
    • Painting
  • Privacy Policy
You are here: Home / Technology / Linux / Setting up a Bond and Bridge in Netplan on Ubuntu 18.04

Setting up a Bond and Bridge in Netplan on Ubuntu 18.04

2018/09/12 by sudo 2 Comments

For some of my Ubuntu 18.04 servers, I need to run KVM virtual machines which require a bridge to the network so the machines get public LAN IP addresses and aren’t hidden behind NAT. With the server configuration for both my co-location and servers at work the network interfaces are all bonded for fail-over. This means I need a bond to have a bridge ontop of it for the virtual machines to get public IP addresses, while still allowing for failover of the network connection in the event of a network failure.

Research

There are some good examples of setting up netplan here: https://netplan.io/examples

They have a bridge example:

network:
  version: 2
  renderer: networkd
  bridges:
    br0:
      dhcp4: yes
      interfaces:
        - enp3s0

And a bond example:

network:
  version: 2
  renderer: networkd
  bonds:
    bond0:
      dhcp4: yes
      interfaces:
        - enp3s0
        - enp4s0
      parameters:
        mode: active-backup
        primary: enp3s0

But there’s not a clear indication of how to amalgamate the two.

A bond and a bridge

Here’s what I’ve ended up with in ‘/etc/netplan/50-cloud-init.yaml’:

network:
    bridges:
        br0:
            addresses:
            - 192.168.10.30
            dhcp4: false
            gateway4: 192.168.10.1
            nameservers:
                addresses:
                - 192.168.10.1
                - 192.168.10.2
                search: []
            interfaces:
                - bond0
    bonds:
        bond0:
            interfaces:
            - eno1
            - eno2
            parameters:
                mode: active-backup
    ethernets:
        eno1:
            addresses: []
            dhcp4: false
            dhcp6: false
        eno2:
            addresses: []
            dhcp4: false
            dhcp6: false

Note that I’ve obviously defined static IP addresses, but this isn’t a requirement. Just set ‘dhcp4: true’ and remove the ‘address’, ‘gateway’ and ‘nameserver’ sections if you’re using DHCP.

Once the file’s got that setup in it, it’s possible to run:
sudo netplan apply
and you should be able to run ‘networkctl list’ to check the bridge and bond are setup.

Related

Filed Under: Linux Tagged With: KVM, Linux, networking, ubuntu 18.04, ubuntu server

Comments

  1. Benjamin Hugo says

    2019/07/05 at 13:18

    Thanks for a great article

    I’m documenting a fix for people who rely on DHCP to assign a static IP based on mac-address. Before installing the bridge (to connect KVM VMs) we had the mac-address set on the bond interface. It seems the bridge DHCP4 settings somehow superceeds the bond DHCP4 settings. The solution is to transfer the mac-address of the bond onto the bridge in a setting that looks something like the following:
    01-netplan.yaml

    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
      version: 2
      renderer: networkd
      ethernets:
        eno1:
          dhcp4: false
          dhcp6: false
          addresses: []
          optional: true
        eno2:
          dhcp4: false
          dhcp6: false
          addresses: []
          optional: true
        eno3:
          dhcp4: true
          dhcp6: true
          dhcp4-overrides:
            route-metric: 1024
          dhcp6-overrides:
            route-metric: 1024
          optional: true
    
      bonds:
        bond0:
          interfaces: [eno1,eno2]
          addresses: []
          optional: true
          parameters:
            mode: 802.3ad
            lacp-rate: fast
            mii-monitor-interval: 100
            transmit-hash-policy: layer2
    

    03-bridges.yaml

    network:
      bridges:
        brvm:
          interfaces: [bond0]
          dhcp4: true
          dhcp6: true
          dhcp4-overrides:
            route-metric: 0
          dhcp6-overrides:
           route-metric: 0
          macaddress: xx:xx:xx:xx:xx:xx
    
          parameters:
            stp: false
            forward-delay: 0
    

    Running networkctl status -a you should get something like the following after applying and (probably) rebooting
    “`
    ● 1: lo
    Link File: /lib/systemd/network/99-default.link
    Network File: n/a
    Type: loopback
    State: carrier (unmanaged)
    Address: 127.0.0.1
    ::1

    ● 2: eno1
    Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-eno1.network
    Type: ether
    State: carrier (configured)
    Path: pci-0000:01:00.0
    Driver: bnx2x
    Vendor: Broadcom Limited
    Model: NetXtreme II BCM57800 1/10 Gigabit Ethernet (BCM57800 10-Gigabit Ethernet)
    HW Address: xx:xx:xx:xx:xx:xx
    Connected To: strubendca7.switch.ru.ac.za on port Te1/0/7 (elwood)

    ● 3: eno2
    Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-eno2.network
    Type: ether
    State: carrier (configured)
    Path: pci-0000:01:00.1
    Driver: bnx2x
    Vendor: Broadcom Limited
    Model: NetXtreme II BCM57800 1/10 Gigabit Ethernet (BCM57800 10-Gigabit Ethernet)
    HW Address: xx:xx:xx:xx:xx:xx
    Connected To: strubendca7.switch.ru.ac.za on port Te1/0/8 (elwood)

    ● 4: eno3
    Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-eno3.network
    Type: ether
    State: routable (configured)
    Path: pci-0000:01:00.2
    Driver: bnx2x
    Vendor: Broadcom Limited
    Model: NetXtreme II BCM57800 1/10 Gigabit Ethernet (BCM57800 1-Gigabit Ethernet)
    HW Address: xx:xx:xx:xx:xx:xx (Dell Inc.)
    Address: 146.231.135.142
    2001:4200:1010:1548:baca:3aff:feec:7855
    fe80::baca:3aff:feec:7855
    Gateway: 146.231.135.129
    DNS: 146.231.129.97
    146.231.129.102
    Search Domains: ru.ac.za
    NTP: 146.231.129.81
    146.231.129.86
    Connected To: strubendca7-mgmt.switch.ru.ac.za on port 1/0/15

    ● 5: eno4
    Link File: /lib/systemd/network/99-default.link
    Network File: n/a
    Type: ether
    State: off (unmanaged)
    Path: pci-0000:01:00.3
    Driver: bnx2x
    Vendor: Broadcom Limited
    Model: NetXtreme II BCM57800 1/10 Gigabit Ethernet (BCM57800 1-Gigabit Ethernet)
    HW Address: xx:xx:xx:xx:xx:xx (Dell Inc.)
    ● 6: brvm
    Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-brvm.network
    Type: ether
    State: routable (configured)
    Driver: bridge
    HW Address: xx:xx:xx:xx:xx:xx (Dell Inc.)
    Address: 146.231.135.133
    2001:4200:1010:1548:baca:3aff:feec:7851
    fe80::baca:3aff:feec:7851
    Gateway: 146.231.135.129
    DNS: 146.231.129.97
    146.231.129.102
    Search Domains: ru.ac.za
    NTP: 146.231.129.81
    146.231.129.86

    ● 7: bond0
    Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-bond0.network
    Type: ether
    State: carrier (configured)
    Driver: bonding
    HW Address: xx:xx:xx:xx:xx:xx

    Reply
  2. Wynand says

    2020/01/12 at 03:59

    Got an error but after changing from

    bridges:
    br0:
    addresses:
    – 192.168.10.30

    to
    bridges:
    br0:
    addresses:
    – 192.168.10.30/24

    It worked

    Thanks for this post really helped

    Reply

Leave a ReplyCancel reply

Recent Posts

  • System Hang on Ubuntu 24.04 “e1000_print_hw_hang”
  • Disable iLO on HP Microserver Gen8
  • Ubuntu Desktop 24.04 Change Wallpaper Settings
  • Customising Ubuntu Desktop 24.04
  • Remove domains from Let’s Encrypt using Certbot

Tags

API auditing crochet data recovery debian debudding development Dingo API docker email Getting started with Laravel 5 & Dingo API hard drive health HP Microserver KVM Laravel larvel 5 lenovo Linux Minion mint netgear nas networking network shares php PHP development Postfix raspberry pi review samba security SMART smartctl smartmontools smb testing traefik ubuntu ubuntu 18.04 ubuntu 20.04 ubuntu 22.04 ubuntu server vagrant Virtual machines xdebug xubuntu

© Copyright 2015 apt get life