HostOnNet Blog

OpenVZ ubuntu guest have not networking

Looking for Linux Server Admin or WordPress Expert? We can help.

I created an OpenVZ vps with ubuntu template ubuntu-9.10-x86.tar.gz

After login to VPS, there was no networking enabled in the VPS

root@server70 [/vz/template/cache]# vzctl enter 102
entered into CT 102
root@hosthat:/# ifconfig
root@hosthat:/# ping yahoo.com
ping: unknown host yahoo.com
root@hosthat:/#

Whrn i restarted networking, i got error

root@hosthat:/# /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                                                                        /etc/network/interfaces:15: interface lo declared allow-auto twice
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:15: interface lo declared allow-auto twice
ifup: couldn't read interfaces file "/etc/network/interfaces"
                                                                                                                       [fail]
root@hosthat:/#

It says

/etc/network/interfaces:15: interface lo declared allow-auto twice

I checked file /etc/network/interfaces and found two entry for lo

root@hosthat:/dev# cat /etc/network/interfaces
# This configuration file is auto-generated.
# WARNING: Do not edit this file, otherwise your changes will be lost.
# Please edit template /etc/network/interfaces.template instead.


auto lo
iface lo inet loopback
        address 127.0.0.1
        netmask 255.0.0.0
        broadcast 127.255.255.255
        up ip route replace 127.0.0.0/8 dev lo


# Auto generated interfaces
auto lo
iface lo inet loopback

auto venet0
iface venet0 inet static
        address 127.0.0.1
        netmask 255.255.255.255
        broadcast 0.0.0.0
        up route add -net 192.0.2.1 netmask 255.255.255.255 dev venet0
        up route add default gw 192.0.2.1
auto venet0:0
iface venet0:0 inet static
        address 67.228.104.123
        netmask 255.255.255.255
        broadcast 0.0.0.0

root@hosthat:/dev#

This is fixed by commenting lo entry in file /etc/network/interfaces.template

root@hosthat:/dev# cat /etc/network/interfaces.template

auto lo
iface lo inet loopback
        address 127.0.0.1
        netmask 255.0.0.0
        broadcast 127.255.255.255
        up ip route replace 127.0.0.0/8 dev lo

root@hosthat:/dev# vi /etc/network/interfaces

After commenting, the file content look like

#auto lo
#iface lo inet loopback
#        address 127.0.0.1
#        netmask 255.0.0.0
#        broadcast 127.255.255.255
#        up ip route replace 127.0.0.0/8 dev lo

After rebooting, network interfaces started working properly.

root@hosthat:/# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2550 (2.5 KB)  TX bytes:2550 (2.5 KB)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:316733 errors:0 dropped:0 overruns:0 frame:0
          TX packets:168152 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:473833406 (473.8 MB)  TX bytes:9101935 (9.1 MB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:67.228.104.123  P-t-P:67.228.104.123  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

root@hosthat:/#

Posted in Virtualization

One Response to OpenVZ ubuntu guest have not networking

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.