Skip to main content
Version: 2.0

NAT

VirtFusion supports NAT IPv4 addressing in conjunction with native IPv6. This allows you to have a single IPv4 address per hypervisor and manage port and domain forwarding on a per VM basis within VirtFusion.

Current Limitations
  • Can't be used on a control/hypervisor combo due to proxy access on ports 80 & 443
  • IPv4 NAT will only function correctly using a VM primary interface.
  • Migrations are not currently supported.

Hypervisor Setup

Prerequisites

Install Dnsmasq

apt install dnsmasq -y

Install HAProxy

apt install haproxy -y

Configure Network

Create a file named network.xml with the following contents. You may change the IP ranges defined, but it's recommended to specify them in /24 ranges for maximum VM OS compatibility.

You should also change the device name dev='eth0' to suit your hypervisor primary network name.

<network>
<name>natbr0</name>
<forward dev='eth0' mode='nat'/>
<bridge name='natbr0' stp='on' delay='0'/>
<ip address='192.168.200.1' netmask='255.255.255.0'/>
<ip address='192.168.201.1' netmask='255.255.255.0'/>
<ip address='192.168.202.1' netmask='255.255.255.0'/>
<ip address='192.168.203.1' netmask='255.255.255.0'/>
<ip address='192.168.204.1' netmask='255.255.255.0'/>
<ip address='192.168.205.1' netmask='255.255.255.0'/>
<ip address='192.168.206.1' netmask='255.255.255.0'/>
<ip address='192.168.207.1' netmask='255.255.255.0'/>
<ip address='192.168.208.1' netmask='255.255.255.0'/>
<ip address='192.168.209.1' netmask='255.255.255.0'/>
</network>

If you would also like native IPv6 on the primary interface you will need to specify it within the configuration. It should be a valid IPv6 address and specified as a /64 if possible. This will be used as the gateway for your IPv6 range.

<ip family='ipv6' address='2a01:4f8:242:4aa6:2::2' prefix='64'/>

Once you have your configuration, you should define the network, set it to autostart and start it.

virsh net-define --file network.xml
virsh net-autostart natbr0
virsh net-start natbr0

VirtFusion Setup

IP Blocks

Configure the local IP blocks as normal ip blocks. For example 192.168.200.1/24 with a gateway of 192.168.200.1, netmask of 255.255.255.0 and add the ips as a /24 subnet.

info

Don't forget to reserve the usual non-usable ips from the range for compliance (.0, .1, .255).

Hypervisor Network

Either create a new network or edit the primary network under the hypervisor settings and set the Type to NAT v1 and the Interface Name to natbr0 (or whichever name you used for the network in the XML configuration earlier).

nat