网络访问行为问题

网络访问行为问题

我的 PC 上安装了 Debian Wheezy 64 位。问题是在某些情况下我只能 ping 通localhost并且127.0.0.1无法访问外部世界。在其他情况下,我可以 ping 通除 之外的任何地方localhost

这是/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

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

这是/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

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

这是/run/network/ifstate

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

    lo=lo
    eth0=eth0

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

重新启动后,ping localhost失败并ping [rest of the world]工作。但在网络服务重新启动后,才ping localhost有效。

答案1

解决方案

文件 /etc/nsswitch.conf 必须存在并包含以下行:

    hosts: dns files

就我而言,它已解决。不知道为什么,里面是空的!

相关内容