無需任何 DNS 伺服器即可解析本機主機?

無需任何 DNS 伺服器即可解析本機主機?

有沒有辦法在沒有任何 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使用主機名,因為它將包含主機檔案。

為什麼我的 /etc/hosts 檔案在...時沒有被查詢

相關內容