These days I have been working with many Proxmox Containers for virtualization, both OpenVZ and KVM. When running some CentOS VM inside containers, I faced the problem of internet connection when assigning IPs to VMs. After resolving the issue, I would like to take some notes regarding how to fix the problem of Promox VM cannot connect to internet.
Firstly, if you cannot create an OpenVZ, check to be sure that your container is starting with PVE kernel. The following commands might help you delete Linux kernel and update boot loaders:
apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64 update-grub
Well, then steps to debugging the problem of internet connection inside VM are as follows:
- First, check if the Host can ping the IP:
. If IP is ping-able, it means that we did assign IP to VM correctly, but it just cannot connect to the outside internet.
- Enter the VM from the Host:
vzctl enter 100
- Check if the network interface is up with ifconfig
- Try pinging outside again to see the problem:
- Check the IP routing table:
. I did see the following result:
XXX.XXX.XXX.56/29 dev eth0 proto kernel scope link src XXX.XXX.XXX.59 XXX.254.0.0/16 dev eth0 scope link metric 1003
- So the problem is there: There is no route to the gateway, which is XXX.XXX.XXX.57. So we must add it to the routing table:
/sbin/route add -net 0.0.0.0 gw XXX.XXX.XXX.57
All is good now. Try yourself to see if this tip solve your current problem 🙂