我的电脑上安装了Debian 64位。问题是,在某些情况下,我只能ping localhost和127.0.0.1,而无法访问外部世界。在其他情况下,我可以在除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才能工作。
发布于 2015-08-03 12:40:01
解决方案
文件/etc/nsswitch.conf必须存在并包含以下行:
hosts: dns files在我的案子中它被解决了。不知道为什么,但它是空的!
https://unix.stackexchange.com/questions/219870
复制相似问题