interfaceDefineXML
and XMLDesc
can be found in the file docs/schema/interface.rng
of the libvirt repository, available at https://gitlab.com/libvirt/libvirt/. Below are some examples of common interface configurations.
Example 7.1. XML definition of an ethernet interface using DHCP
<interface type='ethernet' name='eth0'> <start mode='onboot'/> <mac address='aa:bb:cc:dd:ee:ff'/> <protocol family='ipv4'> <dhcp/> </protocol> </interface>
Example 7.2. XML definition of an ethernet interface with static IP
<interface type='ethernet' name='eth0'> <start mode='onboot'/> <mac address='aa:bb:cc:dd:ee:ff'/> <protocol family='ipv4'> <ip address="192.168.0.5" prefix="24"/> <route gateway="192.168.0.1"/> </protocol> </interface>
Example 7.3. XML definition of a bridge device with eth0 and eth1 attached
<interface type="bridge" name="br0"> <start mode="onboot"/> <mtu size="1500"/> <protocol family="ipv4"> <dhcp/> </protocol> <bridge stp="off" delay="0.01"> <interface type="ethernet" name="eth0"> <mac address="ab:bb:cc:dd:ee:ff"/> </interface> <interface type="ethernet" name="eth1"/> </bridge> </interface>
Example 7.4. XML definition of a vlan interface associated with eth0
<interface type="vlan" name="eth0.42"> <start mode="onboot"/> <protocol family="ipv4"> <dhcp peerdns="no"/> </protocol> <vlan tag="42"> <interface name="eth0"/> </vlan> </interface>