1

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'>
  <name>default</name>
  <uuid>d5a1865e-fd35-4b15-994b-8c5f098e0b5a</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:59:68:25'/>
  <ip address='10.0.0.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='10.0.0.2' end='10.0.0.254'/>
      <host mac='52:54:00:18:41:51' name='host0' ip='10.0.0.2'/>
      <host mac='52:54:00:0a:20:20' name='host1' ip='10.0.0.3'/>
      <host mac='52:54:00:f1:05:fd' name='host2' ip='10.0.0.4'/>
      <host mac='52:54:00:de:74:22' name='host3' ip='10.0.0.5'/>
    </dhcp>
  </ip>
</network>

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)?

0

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.

Example

/etc/network/interfaces (On host):

auto br0
iface br0 inet static
    address 10.0.0.1/24
    netmask 255.0.0.0
    bridge_stp      on
    bridge_maxwait  0

/etc/network/interfaces (On VMs):

auto eth0
iface eth0 inet static
    address 10.0.0.1/24
    netmask 255.0.0.0

VM configuration:

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

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.