OLVM KVM VLAN Tagging Command Line

In this blogpost we will see practical libvirt XML network definition and Linux bridge configuration with VLAN tagging in a KVM environment.
<network>
  <name>vlan100-net</name>
  <forward mode='bridge'/>
  <bridge name='br0.100' />
  <virtualport type='openvswitch'/>
</network>
  
or using the tag (if attaching to a base bridge and tagging per guest):
<interface type='bridge'>
  <source bridge='br0'/>
  <vlan>
    <tag id='100'/>
  </vlan>
  <model type='virtio'/>
</interface>

In this setup: Traffic is tagged with VLAN ID 100. The VM connects to br0, and libvirt applies the tag. Linux Bridge Configuration with VLAN Sub-interface (Manual or via nmcli):
# Create VLAN sub-interface
ip link add link eth0 name eth0.100 type vlan id 100
ip link set eth0.100 up

# Create bridge and attach VLAN interface
ip link add name br100 type bridge
ip link set eth0.100 master br100
ip link set br100 up
Or using nmcli (NetworkManager):
# Create VLAN interface
nmcli connection add type vlan con-name vlan100 dev eth0 id 100

# Create bridge
nmcli connection add type bridge con-name br-vlan100 ifname br-vlan100

# Add VLAN to bridge
nmcli connection add type bridge-slave ifname vlan100 master br-vlan100
VM XML Example (VLAN-aware interface):
<interface type='bridge'>
  <source bridge='br100'/>
  <model type='virtio'/>
</interface>


Using VLAN tagging on the KVM command line provides granular control over VM networking, essential for scalable and secure virtualized infrastructures. Mastery of these CLI tools allows efficient and repeatable network setups without reliance on a GUI.

Comments

Popular posts from this blog

Disable Firewall on Oracle Linux 8

Installation of Oracle Applications R12.1.1 on Linux and vmware

Enable Desktop on Oracle Solaris 11.4