使用ISP DNS服务器而不是本地DNS

问题

在我公司的内部网络上,有一个名为devserver.mycompany.com的开发服务器

通常我可以在没有问题的情况下连接到此服务器,但有时(对我来说似乎是随机的)Ubuntu将无法解析该地址。

其他信息和观察

当我在终端中运行nmcli dev list iface eth0时,我看到有两个配置的DNS服务器:

 IP4.DNS[1]: 192.168.50.103 IP4.DNS[2]: 128.255.1.3 

第二个DNS服务器是我的ISP服务器。

我的Windows分区上没有遇到此问题,该分区配置为使用相同的两个DNS服务器。

当我遇到问题时:

  • nslookup devserver.mycompany.com 失败
  • nslookup devserver.mycompany.com 128.255.1.3 失败 (毫不奇怪,devserver不是公共服务器)
  • nslookup devserver.mycompany.com 192.168.50.103 有效

这是nslookup的实际输出:

 Ubuntu-14:~$ nslookup devserver.mycompany.com Server: 127.0.1.1 Address: 127.0.1.1#53 ** server can't find devserver.mycompany.com: NXDOMAIN 

问题

  • 从上面的输出,看起来Ubuntu正在尝试使用本地DNS服务器。 正确? 它是否在本地计算机上缓存失败的查找?
    • 如果是缓存,我该如何清除缓存?
  • Ubuntu有时会使用第二个DNS服务器吗? 为什么? 负载均衡吗? 本地人慢吗?
  • 我该怎么解决这个问题? 我不想删除第二台DNS服务器以防主要服务器发生故障。
  • 最后,为什么我不在Windows中遇到这个问题?

Ubuntu版本信息

ubuntu 14.04 LTS没有未完成的更新。

所有网络都或多或少地自动设置。 使用DHCP

从上面的输出,看起来Ubuntu正在尝试使用本地DNS服务器。 正确? 它是否在本地计算机上缓存失败的查找?

是的,Ubuntu正在使用dhcp lease提供的任何东西,更具体地说是dnsmasq ,一个插件,它负责network-manager

Ubuntu有时会使用第二个DNS服务器吗? 为什么? 负载均衡吗? 本地人慢吗?

如果第一个DNS无法解析,则dnsmasq应将查询重定向到辅助dns。 至少这是个主意。

如果您想使用自己的DNS服务器 ,我个人总是在/etc/dhcp/dhclient.conf使用supersede domain-name-server xxx.xx.xxx.xxx来告诉我的Ubuntu系统替换任何dns它通过dhcp租用我自己的服务器接收。 这是该文件的摘录:

 30)serg@ubuntu[/home/xieerqi] >_ cat /etc/dhcp/dhclient.conf # Configuration file for /sbin/dhclient, which is included in Debian's # dhcp3-client package. # # This is a sample configuration file for dhclient. See dhclient.conf's # man page for more information about the syntax of this file # and a more comprehensive list of the parameters understood by # dhclient. # # Normally, if the DHCP server provides reasonable information and does # not leave anything out (like the domain name, for example), then # few changes must be made to this file, if any. # option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; #send host-name "andare.fugue.com"; send host-name = gethostname(); #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; #send dhcp-lease-time 3600; #supersede domain-name "fugue.com home.vix.com"; supersede domain-name-servers 208.67.220.220; #prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, dhcp6.name-servers, dhcp6.domain-search, netbios-name-servers, netbios-scope, interface-mtu, rfc3442-classless-static-routes, ntp-servers, dhcp6.fqdn, dhcp6.sntp-servers; 

设置完并重新连接或重新启动network-manager ,这就是我所拥有的:

 31)serg@ubuntu[/home/xieerqi] >_ nmcli dev list | grep -i dns IP4.DNS[1]: 208.67.220.220 

Nslookup将报告Server: 127.0.1.1Address: 127.0.1.1#53因为它是侦听该地址的Network-Manager的dsnmasq ,它使用dhcp提供的任何内容(在本例中为替换的dns)