Promox VM cannot connect to internet

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:

[bash]apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64
update-grub[/bash]

Well, then steps to debugging the problem of internet connection inside VM are as follows:

  1. First, check if the Host can ping the IP:

    [bash]ping XXX.XXX.XXX.59[/bash]

    . If IP is ping-able, it means that we did assign IP to VM correctly, but it just cannot connect to the outside internet.

  2. Enter the VM from the Host:

    [bash]vzctl enter 100[/bash]

  3. Check if the network interface is up with ifconfig
  4. Try pinging outside again to see the problem:

    [bash]ping 8.8.8.8[/bash]

  5. Check the IP routing table:

    [bash]ip route[/bash]

    . I did see the following result:

    [bash]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 [/bash]

  6. 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:
    [bash]/sbin/route add -net 0.0.0.0 gw XXX.XXX.XXX.57[/bash]

All is good now. Try yourself to see if this tip solve your current problem 🙂

Leave a comment

Your email address will not be published. Required fields are marked *