How to configure the network to allow virtual machines to access the Internet via the master node

From ISPWiki
Jump to: navigation, search
Hierarchy: VMmanager KVM ->NETWORKS
VMmanager Cloud ->NETWORKS

This article describes how to configure the system to create virtual machines in a local network with access to the Internet.

Cluster configuration algorithm:

1. To add the IP pool of the local network in Settings -> IP pool or in IPmanager. Reserve the IP addresses from that subnet for the cluster nodes; 2. Configure the IP address from the local network on the cluster nodes:

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-vmbr0:0
IPADDR=<IP address>
NETMASK=<network mask>
EOF
vmbr0 — the name of the virtual network bridge.
<IP address > — the IP address of from the local network.
<network mask> — network mask.

3. Restart the network on the cluster nodes:

service network restart

4. Check the connection between the cluster nodes:

ping <IP address of the cluster node>

5. To configure the NAT on the master node, edit the /etc/sysconfig/iptables file and add the following line into *nat:

-A POSTROUTING -s <local network> ! -d <IP address> -o vmbr0 -j MASQUERADE
<local network> — enter as "network address / mask".
<IP address> — the public IP on the master node.
vmbr0 — the name of the virtual network bridge.

6. Restart iptables:

systemctl iptables restart

After you configure the system, you can create virtual machines with the IP addresses from the pool. The machines will have access to the Internet, but they won't be accessible from the outside.