0

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

Here is /etc/hosts

=======================================

    127.0.0.1   localhost
    127.0.0.1   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
        address 192.168.5.65
        netmask 255.255.255.0
        network 192.168.5.0
        broadcast 192.168.5.255
        gateway 192.168.5.1
    # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.5.1 8.8.8.8 4.4.4.4

    #iface eth0 inet static
    #   address 192.168.5.65
    #   netmask 255.255.255.0
    #   gateway 192.168.5.1
    #auto eth0

    #allow-hotplug eth0
    #iface eth0 inet dhcp

=======================================

And here is /run/network/ifstate

=======================================

    lo=lo
    eth0=eth0

=======================================

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 127.0.1.1 my-pc or <permanent ip> my-pc. – neuron Aug 3 '15 at 12:14
0

Solution

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.