VLAN Connections 101

Prior to this tutorial I have always showed how to use VLANs in conjunction with LXD and Docker. This video explores how to modify the network configuration of a Desktop or a Server to create a bridge to a particular VLAN.

We explored a sample use of Netplan in Ubuntu to configure a desktop or server to use a VLAN as its default connection.

Since these commands all require privilege, I became the root user with the sudo command:

sudo su

Netplan is a YAML code based program to configure the network in Ubuntu. I moved over to the netplan folder:

cd /etc/netplan

You can backup your existing netplan files before making changes. The number that a Netplan file begins with controls the order of processing if you have more than one netplan YAML file in this folder.

I edited my netplan file and deleted the contents and replaced it with the following:

  version: 2
  renderer: networkd
      dhcp4: no
      dhcp6: no
      dhcp4: yes
      dhcp6: no
      interfaces: [ vlan100]
         - to: default
          - ""
          - ""
      id: 100
      link: enp5s0
      dhcp4: no
      dhcp6: no

The above is just an example. You will want to change “enp5s0” in the ethernets section and in the vlans section to match the name of your physical ethernet device which you can determine with the following command:

ip a

You will also want to adjust vlan100 and the id value in the vlans section to match the VLAN that you have created. In my example, we used the Ubiquiti UDM Pro software defined network controller to configure VLAN 100, its address range, gateway, and DHCP scope. All routers do this differently.

Once your netplan YAML file is properly edited, you can apply the configuration with the following command:

netplan apply

I also discussed how a port on a managed switch can be set to a VLAN in lieu of using netplan. This is not advised though because it dedicates the system NIC on that switch port to only one VLAN. Whereas netplan can define multiple VLAN interfaces on one switch port if the switch port is not restricted.