我有个奇怪的问题。它开始于PostgreSQL9.3没有安装。我发现它找不到localhost。
我检查了/etc/hosts,它正确地将localhost作为127.0.0.1
但当我
ping localhost我得到了
PING localhost.Home (198.105.244.21) 56(84) bytes of data.当我
whois 198.105.244.21我在科罗拉多州得到了"SearchGuide公司“
如何使我的系统正确地识别本地主机?
我正在运行可信的tahr 14.04.2 lts
这是我的/etc/hosts文件:
127.0.0.1 localhost
127.0.0.1 ourcomp
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters我之前有个打字错误。现在,它已得到纠正。
下面是nslookup localhost的输出:
nslookup localhost
Server: 127.0.1.1
Address: 127.0.1.1#53
Non-authoritative answer:
Name: localhost.Home
Address: 198.105.244.21
Name: localhost.Home
Address: 198.105.254.21iptables -L的输出:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination ufw状态是不活动的
/etc/nsswitch为空白
/etc/resolv.conf的内容:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search Homeifconfig:
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:46904 errors:0 dropped:0 overruns:0 frame:0
TX packets:46904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2538766 (2.5 MB) TX bytes:2538766 (2.5 MB)
p5p1 Link encap:Ethernet HWaddr f0:4d:a2:9b:3b:b9
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:1b:b1:81:06:3d
inet addr:192.168.0.14 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21b:b1ff:fe81:63d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8968 errors:0 dropped:0 overruns:0 frame:0
TX packets:7779 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4212369 (4.2 MB) TX bytes:1142565 (1.1 MB)发布于 2015-07-09 13:24:53
结果发现,问题是/etc/nsswitch配置文件中缺少相关条目。
在将主机名解析为IP地址时,GNU库libc使用此文件获取源和查询顺序。这里涉及的/etc/nsswitch.conf的数据库名是hosts。libc还可以理解许多其他数据库,如passwd、protocols等。
在行的开头会提到数据库,后面跟着要查询的源的名称。例如,hosts数据库所需的配置(用于查找主机的IP地址)可以采用以下形式:
hosts: files mdns4 dnsfiles表示首先要查询/etc目录中的相关配置文件,因此首先查询/etc/hosts。由于您的/etc/nsswitch配置文件不包含任何内容,我建议您将默认条目放入该文件:
passwd: compat
group: compat
shadow: compat
hosts: files mdns4 mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis查看man 5 nsswitch.conf以获得更多的想法。
https://askubuntu.com/questions/646345
复制相似问题