我只对sun / etc / hosts中的主机名/ IP进行了硬编码:
# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.42.1 sun sun.beowulf.IEcs192.168.42.2 mercury mercury.beowulf.IEcs
目前,eth0(面向WAN)的IP地址是通过DHCP分配的(sun eth0始终被分配相同的IP;这是大学的工作方式,但我正在将此更改为允许我分配一个静态IP).我在sun上的/etc/resolv.conf是:
; generated by /sbin/dhclIEnt-scriptsearch biol.uregina.canameserver 142.3.102.202nameserver 142.3.100.15
当我重新启动时似乎被覆盖了所以我有以下/etc/dnsmasq-resolv.conf
search beowulf.IEcs biol.uregina.canameserver 127.0.0.1nameserver 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.confresolv-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.confstrict-order
大多数情况下,此设置正常.我遇到的问题(我不确定它是一个主要问题,但是……)是nslookup和dig都无法解析sun和mercury的名称,除非我通知这些命令要查询哪个DNS服务器:
# nslookup sun.beowulf.IEcs sun.beowulf.IEcsServer: sun.beowulf.IEcsAddress: 192.168.42.1#53name: sun.beowulf.IEcsAddress: 192.168.42.1# nslookup sun sun.beowulf.IEcsServer: sun.beowulf.IEcsAddress: 192.168.42.1#53name: sunAddress: 192.168.42.1# nslookup sunServer: 142.3.102.202Address: 142.3.102.202#53** server can't find sun: NXDOMAIN# nslookup sun.beowulf.IEcsServer: 142.3.102.202Address: 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 sunnameserver 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.confsearch beowulf.IEcs biol.uregina.canameserver 8.8.8.8
如果你想使用谷歌的名称服务器.使用大学名称服务器142.3.102.202& amp;是一个好主意. 142.3.100.15相反,因为只有校园网可以看到某些资源并不罕见.
如果您的水银主机是由DHCP配置的,它应该从dnsmasq获取配置,而/etc/resolv.conf指向192.168.42.1上的dnsmasq名称服务器
总结以上是内存溢出为你收集整理的domain-name-system – 除非我指定要使用的(本地)DNS服务器,否则dig&nslookup无法解析本地主机全部内容,希望文章能够帮你解决domain-name-system – 除非我指定要使用的(本地)DNS服务器,否则dig&nslookup无法解析本地主机所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)