I'm using libvirt, and currently have a NAT based network setup where each host has a static IP. The network config looks like this:

<network connections='4'>
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:59:68:25'/>
  <ip address='' netmask=''>
      <range start='' end=''/>
      <host mac='52:54:00:18:41:51' name='host0' ip=''/>
      <host mac='52:54:00:0a:20:20' name='host1' ip=''/>
      <host mac='52:54:00:f1:05:fd' name='host2' ip=''/>
      <host mac='52:54:00:de:74:22' name='host3' ip=''/>

However, I would like to assign an internal subnet to each VM where every IP in that subnet will route to the VM. The only traffic to and from these addresses will be the VMs.

Is this possible with the default libvirt networking at all, and if it is, is it possible to do it on top of the existing network (aka not need to create a new network)?


This is possible if you use a bridge interface, because it acts like a unmanaged switch. Therefore, you can use it to bind as many IPs as you want inside the VM.


/etc/network/interfaces (On host):

auto br0
iface br0 inet static
    bridge_stp      on
    bridge_maxwait  0

/etc/network/interfaces (On VMs):

auto eth0
iface eth0 inet static

VM configuration:

<interface type='bridge'>
  <mac address='xx:xx:xx:xx:xx:xx'/>
  <source bridge='br0'/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.