domain-name-system – 除非我指定要使用的(本地)DNS服务器,否则dig&nslookup无法解析本地主机

前端之家收集整理的这篇文章主要介绍了domain-name-system – 除非我指定要使用的(本地)DNS服务器,否则dig&nslookup无法解析本地主机前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在我的大学网络中建立一个小型私人网络.我的专用网络和大学WAN之间有一个Centos 6盒(太阳). sun上的eth0通过netgear智能交换机连接到WAN,eth1连接到我的专用网络. sun充当专用网络的路由器,使用使用iptables配置的NAT将流量从eth1转发到eth0.私有网络上的客户端(目前只有水银)通过在太阳上运行的dnsmasq分配IP,网关等和主机名. dnsmasq配置为将特定IP和主机名发送到客户端的MAC地址.

我只对sun / etc / hosts中的主机名/ IP进行了硬编码:

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.42.1    sun sun.beowulf.iecs
192.168.42.2    mercury mercury.beowulf.iecs

目前,eth0(面向WAN)的IP地址是通过DHCP分配的(sun eth0始终被分配相同的IP;这是大学的工作方式,但我正在将此更改为允许我分配一个静态IP).我在sun上的/etc/resolv.conf是:

; generated by /sbin/dhclient-script
search biol.uregina.ca
nameserver 142.3.102.202
nameserver 142.3.100.15

当我重新启动时似乎被覆盖了所以我有以下/etc/dnsmasq-resolv.conf

search beowulf.iecs biol.uregina.ca
nameserver 127.0.0.1
nameserver 8.8.8.8

并指示dnsmasq使用它而不是/etc/resolv.conf

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/dnsmasq-resolv.conf

# By  default,dnsmasq  will  send queries to any of the upstream
# servers it knows about and tries to favour servers to are  known
# to  be  up.  Uncommenting this forces dnsmasq to try each query
# with  each  server  strictly  in  the  order  they   appear   in
# /etc/resolv.conf
strict-order

大多数情况下,此设置正常.我遇到的问题(我不确定它是一个主要问题,但是……)是nslookup和dig都无法解析sun和mercury的名称,除非我通知这些命令要查询哪个DNS服务器:

# nslookup sun.beowulf.iecs sun.beowulf.iecs
Server:     sun.beowulf.iecs
Address:    192.168.42.1#53

Name:   sun.beowulf.iecs
Address: 192.168.42.1

# nslookup sun sun.beowulf.iecs
Server:     sun.beowulf.iecs
Address:    192.168.42.1#53

Name:   sun
Address: 192.168.42.1

# nslookup sun
Server:     142.3.102.202
Address:    142.3.102.202#53

** server can't find sun: NXDOMAIN

# nslookup sun.beowulf.iecs
Server:     142.3.102.202
Address:    142.3.102.202#53

** server can't find sun.beowulf.iecs: NXDOMAIN

对于汞而不是**太阳*给出相同的输出.代表性挖掘输出是:

# dig @192.168.42.1 mercury.beowulf.iecs

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @192.168.42.1 mercury.beowulf.iecs
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY,status: NOERROR,id: 65090
;; flags: qr aa rd ra; QUERY: 1,ANSWER: 1,AUTHORITY: 0,ADDITIONAL: 0

;; QUESTION SECTION:
;mercury.beowulf.iecs.      IN  A

;; ANSWER SECTION:
mercury.beowulf.iecs.   0   IN  A   192.168.42.2

;; Query time: 0 msec
;; SERVER: 192.168.42.1#53(192.168.42.1)
;; WHEN: Wed Jun 25 12:05:31 2014
;; MSG SIZE  rcvd: 54

当我没有指定要使用的名称服务器时不工作:

# dig mercury.beowulf.iecs

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> mercury.beowulf.iecs
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY,status: NXDOMAIN,id: 29153
;; flags: qr rd ra; QUERY: 1,ANSWER: 0,AUTHORITY: 1,ADDITIONAL: 0

;; QUESTION SECTION:
;mercury.beowulf.iecs.      IN  A

;; AUTHORITY SECTION:
.           7988    IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2014062500 1800 900 604800 86400

;; Query time: 0 msec
;; SERVER: 142.3.102.202#53(142.3.102.202)
;; WHEN: Wed Jun 25 12:05:37 2014
;; MSG SIZE  rcvd: 113

在上面的最后一个例子(dig)中,SERVER:142.3.102.202#53(142.3.102.202)是/etc/resolv.conf中的第一个DNS服务器,所以默认情况下sun似乎使用这个名称服务器而不是dnsmasq由于/etc/dnsmasq.conf中的设置,预计它会被使用.

那么,这是一个问题吗?我可以在阳光下晒太阳和水银,用SSH连接太阳水银.

如果这是一个问题(或者即使它不是),有没有办法在其上运行sun和dnsmasq来自动解析私有主机名?

解决方法

dig(域信息groper)和nslookup(以交互方式查询Internet名称服务器)是查询名称服务器的工具.除非将特定名称服务器指定为命令行参数,否则它们将查询/etc/resolv.conf中的名称服务器.他们根本不查看主机信息的替代来源,例如/ etc / hosts文件或/etc/nsswitch.conf中指定的其他源.

如果你想通过你的sun主机上的dnsmasq强制所有dns查询,那么/etc/resolv.conf应该指向dnsmasq,即它应该如下所示:

#/etc/resolv.conf on sun
nameserver 127.0.0.1

当您重新启动网络接口eth0编辑/ etc / sysconfig / network-scripts / ifcfg-eth0并添加option PEERDNS = no时,防止该文件被覆盖

在/etc/dnsmasq-resolv.conf中,您尝试将dnsmasq配置为上游名称服务器名称服务器127.0.0.1 …该文件应如下所示:

#/etc/dnsmasq-resolv.conf
search beowulf.iecs biol.uregina.ca
nameserver 8.8.8.8

如果你想使用谷歌的名称服务器.使用大学名称服务器142.3.102.202& amp;是一个好主意. 142.3.100.15相反,因为只有校园网可以看到某些资源并不罕见.

如果您的水银主机是由DHCP配置的,它应该从dnsmasq获取配置,而/etc/resolv.conf指向192.168.42.1上的dnsmasq名称服务器

猜你在找的HTML相关文章