I’m using virsh
manages, so let’s disable default
networking
virsh net-list
You’re going to see default
network enabled.
To disable that run
virsh net-destroy default
# and to disable on start-up
virsh net-autostart --network default --disable
# in case you want to enable it back
virsh net-start default
# to totally remove the network
virsh net-undefine default
That will remove virbr0
created by libvirt
.
Now, we are going to create another libvirt network which then on new VM creation will be generating a macvtap and attach it to the VM.
Let’s create yaml file with network definition named macvtap-def.xml
<network>
<name>macvtap-net</name>
<forward mode="bridge">
<interface dev="eno1"/>
</forward>
</network>
You can change mode if you prefer another, also change dev
to whatever you have.
Now, we can create a network based on that configuration with these commands
virsh net-define macvtap-def.xml
virsh net-autostart macvtap-net
virsh net-start macvtap-net
And when creating a VM with virt-install
add the following
--network network=macvtap-net,model=virtio
That’s it!
P.S. My internet provider was not able to attach an IP to MAC address, MAC appeared and then disappeared. After netplan apply
from virtual machine, he was able to attach IP to my MAC.
Leave a Reply