Help Understanding how to edit/create VM network interfaces

User documentation

  • Last Updated: 06/21/2019

You can copy the xml template of one of the other vms.

If you look in the lab text it gives you an example:

<interface type='bridge'>
      <source bridge='vmbr80'/>
      <model type='virtio'/>

But this example is incomplete as its expected that you will look at a working example and infer what other options need to be added.

Each interface stanza is a NIC (virtual nic) in your computer. Here is an example of a vm that I have that
has 2 nics, 1 on vmbr1023 (i.e. vlan 1023) and the other on vmbr1021 - vlan 1021.

The macs should start with 52:54, and my convention is to place the vlan id in the middle 2 bytes in decimal
(base10) format, and then the last 1 or 2 bytes match the ip address.

So for this vm guest I will assign it (inside the guest vm once its ip) Notice how the mac
address matches it. That makes it easier when you are debugging if the mac address is matched up correctly.
HOWEVER if you duplicate MAC addresses you will cause the network to not function at all. So the downside of
manually administering your MACs is that if you get it wrong and forget to keep them in sync, you will have
a major outage and a frustrating time tracking it down.

Here is a tool that you can use to generate a mac address:

    <interface type='bridge'>
      <mac address='52:54:10:23:01:25'/>
      <source bridge='vmbr1023'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/>

    <interface type='bridge'>
      <mac address='52:54:10:21:00:42'/>
      <source bridge='vmbr1021'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x09' function='0x0'/>

So you can copy a working xml template off a working vm by doing:

virsh dumpxml myvm > myvm.xml

You can now copy myvm.xml to myfw.xml
You can then edit that myfw.xml file to point to the location of the disk image of the pfsense img file you
downloaded. Remove/edit/clone the interface section to create 2 nics as per above (you can create more if
you like).

Each nic must have a unique bus+slot id. So if you try to define to nics with bus='0x02' slot='0x09' you
will get a pci error.

Make sure you also create unique (as always) uuid and name xml tags for your vm. Otherwise it wont be able
to be created as virsh/kvm will consider it a duplicate of another vm by its id number (uuid) or name (vm
dom name). virsh calls the vm guests domains (doms). It just means vm guest name or vm guest.

You can learn more about the format of the xml vm template file by reading up on libvirt and virsh.