Lampros - Weird Bricks

Change the MAC address of a KVM virt

09 October, 2014 | KVM

Quick notes on changing the MAC address of a virt.

First check what is the current MAC address of a virt - in this example freebsd is the virt:

sudo virsh domiflist freebsd

Output:

Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      bridge     bridge0    e1000       52:54:00:da:25:52

A quick one liner that only returns the MAC address:

virsh domiflist freebsd | grep bridge0 | awk '{print $5}'

To set the MAC address of the virt:

sudo virsh edit freebsd

Find the line:

<mac address='52:54:00:9a:4c:34'/>

change it to:

<mac address='52:54:00:da:25:59'/>    

To make the change take effect stop and start the virt:

sudo virsh destroy freebsd

Output:

Domain freebsd destroyed
sudo virsh start freebsd

Output:

Domain freebsd started