I have Debian Wheezy 64 bit installed on my PC. The problem is that in some situations I can only ping localhost and and don't have access to outside world. And in other cases I can ping everywhere but localhost.

Here is /etc/hosts

=======================================   localhost   my-pc

    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters


And here is /etc/network/interfaces


    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    allow-hotplug eth0
    iface eth0 inet static
    # dns-* options are implemented by the resolvconf package, if installed

    #iface eth0 inet static
    #   address
    #   netmask
    #   gateway
    #auto eth0

    #allow-hotplug eth0
    #iface eth0 inet dhcp


And here is /run/network/ifstate




After a restart, ping localhost fails and ping [rest of the world] works. but after any restart in networking service, only ping localhost works.

  • Change your second line to either my-pc or <permanent ip> my-pc. – neuron Aug 3 '15 at 12:14


File /etc/nsswitch.conf must be present and contain the below line:

    hosts: dns files

In my case it was solved. Don't know why, but it was empty!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.