有没有办法在没有任何 DNS 服务器的情况下解析本地主机?
下面是我的配置
# ifconfig
eth4 Link encap:Ethernet HWaddr 00:50:56:9C:4D:2F
inet6 addr: 2004:c0a8:5b01:1:250:56ff:fe9c:4d2f/64 Scope:Global
inet6 addr: fe80::250:56ff:fe9c:4d2f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:196832 errors:0 dropped:0 overruns:0 frame:0
TX packets:12558 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16362576 (15.6 MiB) TX bytes:2467903 (2.3 MiB)
/etc/hosts
我也在文件中添加了名称
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
2004:c0a8:5b01:1:250:56ff:fe9c:4d2f saravana69rhel83
2004:c0a8:5b01:1:250:56ff:fe9c:4d2f localhost localhost.localdomain localhost6 localhost6.localdomain6
::1 saravana69rhel83
当我尝试进行 DNS 查找时,它根本无法解析:
# dig saravana69rhel83 AAAA
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6_9.4 <<>> saravana69rhel83 AAAA
;; global options: +cmd
;; connection timed out; no servers could be reached
编辑
[root@saravana69rhel83 ~]# ping saravana69rhel83
ping: unknown host saravana69rhel83
[root@saravana69rhel83 ~]# ping6 saravana69rhel83
PING saravana69rhel83 (saravana69rhel83 ) 56 data bytes
64 bytes from saravana69rhel83 : icmp_seq=1 ttl=64 time=0.030 ms
^C
--- saravana69rhel83 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 855ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms
[root@saravana69rhel83 ~]#
[root@saravana69rhel83 ~]# nslookup -query=AAAA saravana69rhel83
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached
[root@saravana69rhel83 ~]#
答案1
您使用/etc/hosts
正确,但nslookup
忽略了主机文件。它执行 DNS 查找,而不是查找主机名在您配置的环境中如何解析。尝试ping
使用主机名,因为它将包含主机文件。