DNS主机名解析问题

DNS主机名解析问题

我之前设置的 Linux 服务器无法通过主机名解析:我无法通过主机名访问 ssh 或网站(端口 80,8834),只能通过 IP 访问

我认为我的 /etc/hosts 文件配置良好:

127.0.0.1 localhost
ip_server name_server.domain.corp name_server

我的 resolv.conf 是:

nameserver ip_dns_server_dc01
nameserver ip_dns_server_dc02
search domain.corp

请问有人可以帮助我吗?

提前致谢。

答案1

Per man resolv.conf,该行的语法nameserver ...是:

       nameserver Name server IP address
              Internet address of a name server  that  the  resolver  should
              query,  either  an  IPv4 address (in dot notation), or an IPv6
              address in colon (and possibly dot) notation as per RFC  2373.
              Up  to MAXNS (currently 3, see <resolv.h>) name servers may be
              listed, one per keyword.  If there are multiple  servers,  the
              resolver  library  queries  them  in  the order listed.  If no
              nameserver entries are present, the default is to use the name
              server  on the local machine.  (The algorithm used is to try a
              name server, and if the query times out, try the  next,  until
              out  of  name servers, then repeat trying all the name servers
              until a maximum number of retries are made.)

基本上,所有这些行:

nameserver ip_dns_server_dc01
nameserver ip_dns_server_dc02
nameserver dns_service (AD-DC 01)
nameserver dns_service (AD-DC 02)

无效,因为ip_dns_server_dc01不是 IPv4 地址(以点表示法)或 IPV6 地址(以冒号表示法)。

我怀疑您拥有的文件是从某些指令复制而来的,您打算将其替换dns_server为 的 IP 地址DC 01

它应该看起来像:

nameserver 192.168.1.1
nameserver 1.1.1.1 
nameserver 2606:4700:4700::1111

您已将问题从 编辑nameserver dns_service (AD-DC 01)nameserver ip_dns_server_dc01。这个答案仍然适用。但有了这个新的resolv.conf,您就更接近了,因为现在您有了一个可以用 IP 替换的可解析名称。如果您知道 的 IP 地址ip_dns_service_dc01,您可以将服务器的 IP地址添加192.168.1.1 ip_dns_service_dc01到您的服务器中/etc/hosts,以使其正常工作。192.168.1.1不过,如果您有 IP,您实际上应该将其放入resolv.conf.

相关内容