首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >网络访问行为问题

网络访问行为问题
EN

Unix & Linux用户
提问于 2015-08-03 10:22:04
回答 1查看 42关注 0票数 0

我的电脑上安装了Debian 64位。问题是,在某些情况下,我只能ping localhost127.0.0.1,而无法访问外部世界。在其他情况下,我可以在除localhost之外的任何地方切换。

这是/etc/hosts

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

代码语言:javascript
复制
    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

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

代码语言:javascript
复制
    # 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

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

代码语言:javascript
复制
    lo=lo
    eth0=eth0

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

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

EN

回答 1

Unix & Linux用户

发布于 2015-08-03 12:40:01

解决方案

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

代码语言:javascript
复制
    hosts: dns files

在我的案子中它被解决了。不知道为什么,但它是空的!

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/219870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档