No internet connection from guests

Ventzy

Member
Oct 16, 2013
7
0
21
I have simple situation, but I could not get it to work.

I have one machine with Proxmox 3.1.
I have public static IP address and Proxmox host have internet connection (ping google.com works).
I need few VMs (OpenVZ, Ubuntu Server 12) which needs to connection to internet and have IP addresses like 10.0.0.XXX

Network configuartion on the host
Code:
auto lo
iface lo inet loopback


auto eth0
iface eth0 inet static
        address  MY_PUBLIC_IP
        netmask  255.255.255.240
        gateway  MY_PUBLIC_GATEWAY
        post-up echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp




auto vmbr0
iface vmbr0 inet static
        address  10.0.0.1
        netmask  255.255.255.0
        bridge_ports none
        bridge_stp off
        bridge_fd 0

At VM creation I have tried both options - "Routed mode (venet)" with IP 10.0.0.2 and "Bridged mode" with vmbr0. In both cases, there is no ping to MY_PUBLIC_GATEWAY from VM. What is missing?
 
As suspected the solutions is very easy from here http://pve.proxmox.com/wiki/Network_Model#Masquerading

I added following lines at the end of host's /etc/network/interfaces
Code:
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward
        post-up   iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o eth0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o eth0 -j MASQUERADE