How To: Configure multiple VLAN interfaces in SolusVM
There may be times when you wish to give VM’s on one of your SolusVM nodes access to IP resrouces that are segmented into discrete VLAN’s at network level. If this is the case, you need to create network bridge interfaces on the node, and suply them with your VLAN interfaces. This is explained below.
- Configure the base interface, in this example, we ahve trunked eno2 with vlan’s 220 and 221, as we have group of VM’s that require to bind IP’s within this VLAN.
- Configure your VLAN sub interfaces, note that we designate each interface to its own new bridge interface, this is required.
- Configure your bridge interfaces.
- ‘UP’ your interfaces.
- Check the state of your bridges.
- Custom config for a sample VM.
- Checking your bridge status now should show the VM interface active within it.
[root@solus-node01]# cat ifcfg-eno2
DEVICE=eno2
BOOTPROTO=none
UUID=xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ONBOOT=yes
TYPE=Ethernet
NM_CONTROLLED=no
[root@solus-node01]# cat ifcfg-en02.220
VLAN=yes
BRIDGE=br2
DEVICE=eno2.220
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NM_CONTROLLED=no
[root@solus-node01]# cat ifcfg-eno2.221
VLAN=yes
BRIDGE=br1
DEVICE=eno2.221
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NM_CONTROLLED=no
[root@solus-node01]# cat ifcfg-br2
DEVICE=br2
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
[root@solus-node01]# cat ifcfg-br1
DEVICE=br1
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
At this point, if you want the host node to have an IP in this VLAN, you would bind it to the bridge interface directly, you can use the usual IPADDR, PREFIX, GATEWAY etc..
[root@solus-node01]# ifup eno2.220
[root@solus-node01]# ifup eno2.221
[root@solus-node01]# ifup br2
[root@solus-node01]# ifup br1
[root@solus-node01]# brctl show
<some info redacted>
br1 8000.0cc47xxxxxxx no eno2.221
br2 8000.0cc47xxxxxxx no eno2.220
Note you should see your 2 new bridges with the relevant vlan interface attached to it, I’ve removed some data here as I use some odd custom work on br0 that would confuse this article.
Now that you have bridges available, you can begin assigning these to VM’s that need access to it. In my case, I ahd to use KVM Custom Config in SolusVM to be able to A) specifiy the right bridge and B) create a second interface inside the VM.
<domain type='kvm'>
<name>kvmXXX</name>
<uuid>xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<memtune>
<hard_limit>1099776</hard_limit>
</memtune>
<vcpu>4</vcpu>
<cpu>
</cpu>
<os>
<type machine='pc'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
</os>
<clock sync='localtime'/>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<graphics type='vnc' port='xxxx' passwd='xxxxxxxx' listen='0.0.0.0'/>
<disk type='file' device='disk'>
<source file='/dev/vg_xxxxxxxx/kvmXXX_img'/>
<target dev='hda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<target dev='hdc'/>
<readonly/>
</disk>
<interface type='bridge'>
<source bridge='br1'/>
<target dev='kvmXXX.0'/>
<mac address='00:16:3c:xx:xx:xx'/>
</interface>
<interface type='bridge'>
<source bridge='br2'/>
<target dev='kvmXXX.1'/>
</interface>
<input type='tablet'/>
<input type='mouse'/>
</devices>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
</domain>
Note that this is heavily edited, the main focus is the duplicate “interface” section, and that the duplicate has no MAC address specified. You can also see that br1 and br2 have been specified. Make a mental note of which one is which so that in your VM, you can assign IP’s in the relevant VLAN.
Save the custom config and reboot the VM. Assign IP’s once booted into the VM.
[root@solus-node01]# brctl show
<some info redacted>
br1 8000.0cc47axxxxxx no eno2.221
kvmXXX.0
br2 8000.0cc47xxxxxxx no eno2.220
kvmXXX.1