My goal was to configure the following network settings on Ubuntu 18.04 (bionic) using Open vSwitch bridge and ports.

Uplink is a trunk port connected to eth0.

VLAN Tagged Interface IP
trunk   eth0  
100 no vlan100 192.168.100.3
200 yes vlan200 192.168.200.4

Netplan is the default utility on Ubuntu 18.04 (bionic) for configuring network.

Unfortunately Netplan can not brings up Open vSwitch bridges and ports like ifupdown does.

Basically you have the following options:

  1. Install ifupdown which configures IP addresses and Open vSwitch entirerily. Optionally install resolvconf for DNS resolver configuration.
  2. Configure interfaces using ovs-vsctl and configure IP settings using Netplan.
  3. Configure interfaces using ovs-vsctl and configure IP settings using systemd-networkd.

ifupdown

The classic way is installing ifupdown for IP configuration and optionally resolvconf for DNS resolver configuration.

Install packages.

apt-get install ifupdown openvswitch-switch resolvconf

Edit /etc/network/interfaces.

auto br0
allow-ovs br0
iface br0 inet manual
  ovs_type OVSBridge
  ovs_ports eth0 vlan100 vlan200
  dns-nameservers 192.168.100.10
  dns-search example.com

allow-br0 eth0
iface eth0 inet manual
  ovs_bridge br0
  ovs_type OVSPort
  ovs_options vlan_mode=native-untagged tag=100

allow-br0 vlan100
iface vlan100 inet static
  address 192.168.100.3
  netmask 255.255.255.0
  gateway 192.168.100.1
  ovs_type OVSIntPort
  ovs_bridge br0
  ovs_options tag=100

allow-br0 vlan200
iface vlan200 inet static
  address 192.168.200.4
  netmask 255.255.255.0
  ovs_type OVSIntPort
  ovs_bridge br0
  ovs_options tag=200

Note: As README.Debian for openvswitch-switch mentions, and Ubuntu bug #1448254 describes (suggested workaround) auto br0 should not be set in /etc/network/interfaces, however it worked for me under bionic.

Netplan

Netplan does not manage Open vSwitch.

You have to set up Open vSwitch before the IP configuration.

It is very easy to manage Netplan with Ansible, as network configuration can be stored in inventory group or host variables in YAML format.

Install Open vSwitch.

apt-get install openvswitch-switch

Configure Open vSwitch.

ovs-vsctl add-br br0
ovs-vsctl add-port br0 eth0
ovs-vsctl set port eth0 tag=100 vlan_mode=native-untagged
ovs-vsctl add-port br0 vlan100 tag=100 -- set interface vlan100 type=internal
ovs-vsctl add-port br0 vlan200 tag=200 -- set interface vlan200 type=internal

Create Netplan configuration.

network:
  version: 2
  renderer: networkd
  ethernets:
    vlan100:
      dhcp4: no
      addresses:
        - 192.168.100.3/24
      gateway4: 192.168.100.1
      nameservers:
        search: [example.com]
        addresses: [192.168.100.10]
    vlan200:
      dhcp4: no
      addresses:
        - 192.168.200.4/24

Apply configuration.

sudo netplan generate
sudo netplan apply

systemd-networkd

Systemd-networkd does not manage Open vSwitch.

You have to set up Open vSwitch before the IP configuration.

Install and configure Open vSwitch similarly as in Netplan.

/etc/systemd/network/10-eth0.network:

[Match]
Name=eth0

/etc/systemd/network/10-vlan100.network:

[Match]
Name=vlan1

[Network]
Address=192.168.100.3/24
Gateway=192.168.100.1
DNS=192.168.100.10

/etc/systemd/network/10-vlan200.network:

[Match]
Name=vlan11

[Network]
Address=192.168.200.4/24

Restart systemd-networkd.

sudo systemctl restart systemd-networkd

NUT serial support on OpenWrt

24 November 2018 12:32 | Molnár Péter

Using a serial port connected UPS on OpenWrt with NUT.

read more

Disable Intel Hyper-Threading on Linux

02 December 2017 16:15 | Molnár Péter

Disable Intel Hyper-Threading on Linux in software, not in BIOS/UEFI.

read more

Migration from BIND/OpenDNSSEC to PowerDNS with DNSSEC

17 August 2016 15:01 | Molnár Péter

Migration of BIND and OpenDNSSEC to PowerDNS 4 with DNSSEC.

read more

Installing Altera Quartus II 14.0 and ModelSim on Ubuntu Linux 14.10 system

01 November 2014 07:49 | Molnár Péter

Installation of Altera Quartus II 14.0 and setting up of ModelSim Altera Edition on Ubuntu 14.10

read more

Remote FPGA JTAG programming via SSH tunnel with Altera Quartus II

23 October 2014 14:43 | Molnár Péter

JTAG programming of an Altera FPGA, through an SSH tunnel with Quartus II. The device is on the network, connected to a remote machine through USB Blaster.

read more

Altera Quartus II and NIOS II command line tutorial

12 October 2014 08:06 | Molnár Péter

Altera Quartus II and NIOS II command line

read more

IT8720F watchdog

23 March 2013 07:37 | Molnár Péter

Setting up IT8720F watchdog on Linux

read more