Attaching a Guest Directly to a Virtualization Host Network Interface with a macvtap Driver

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

Method 1

The simplest method is to leave the network interface unconfigured on the virtualization host and to assign it to the guest in configuration with virsh edit as follows:


...
<interface type='direct'>
    <source dev='eth0' mode='private'/>
</interface>
...

Note that after saving it, libvirt will update the stored configuration as follows:

...
<interface type='direct'>
    <mac address='52:54:00:02:72:ed'/>
    <source dev='em2' mode='private'/>
    <model type='rtl8139'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</interface>
...

Note that the MAC address declared in the configuration is different from the MAC address declared by ip addr on the virtualization host.

The new network interface shows up on the guest, alongside the default network interface eth1:

ip addr
...
2: ens8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:02:72:ed brd ff:ff:ff:ff:ff:ff
...
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:e4:e6:8a brd ff:ff:ff:ff:ff:ff

After the first boot, figure out the name of the new network interface and add a /etc/sysconfig/network-scripts/ifcfg-<interface-name> configuration file, similar to:

For more details on how to configure network interfaces, see

Configuring a Network Interface

Reboot the second time, both interfaces should be operational.