Linux DNS (nslookup)

0 domain-name-system

我是 DNS 的新手,在我的 linux VM 上安装了 DNS 服务器并且成功了。但是我对 nslookup 的查询很少,我能够解析 FQDN 但无法解析主机名。

Q.) 如何仅使用主机名进行 nslookup。

例如:- 以下主机名失败:-

# nslookup server01
Run Code Online (Sandbox Code Playgroud)

对于具有 FQDN 的相同主机名,以下是成功的:-

# nslookup server01.example.com
Run Code Online (Sandbox Code Playgroud)

以下是我当前的 DNS 配置:-


前向查找区:-

$TTL 86400
@       IN SOA @  server01.example.com.  (
                                2014051001      ; serial
                                        3600    ; refresh
                                        1800    ; retry
                                        604800  ; expire
                                        86400    ; minimum
)
@                     NS      server01.example.com.
                      A       127.0.0.1
@                     A   192.168.0.50
server01              A       192.168.0.50
client01             A       192.168.0.60
Run Code Online (Sandbox Code Playgroud)

反向查找区域:

$TTL 1D
@       IN SOA @        server01.example.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       NS      server01.example.com.
50      PTR     server01.
60      PTR     client01.
Run Code Online (Sandbox Code Playgroud)

猫 /etc/resolv.conf

# Generated by NetworkManager
search server01.example.com
domain server01.example.com
nameserver 192.168.0.50
Run Code Online (Sandbox Code Playgroud)

下面使用 FDQD 的 nslookup 工作:-

# nslookup server01.example.com
Server:         192.168.0.50
Address:        192.168.0.50#53

Name:   server01.example.com
Address: 192.168.0.50

# nslookup client01.example.com
Server:         192.168.0.50
Address:        192.168.0.50#53

Name:   client01.example.com
Address: 192.168.0.60
Run Code Online (Sandbox Code Playgroud)

以下 nslookup 失败,主机名:-

nslookup server01
Server:         192.168.0.50
Address:        192.168.0.50#53

** server can't find server01: NXDOMAIN

nslookup client01
Server:         192.168.0.50
Address:        192.168.0.50#53

** server can't find client01: NXDOMAIN
Run Code Online (Sandbox Code Playgroud)

And*_*w B 8

这按预期工作。短名称最常用于两种情况:

  • 域后缀在/etc/resolv.conf.
  • 短名称在 中定义/etc/hosts

nslookup和类似的 DNS 客户端实用程序的情况下,/etc/hosts不相关,因为这些程序不咨询它。这使您配置的搜索后缀成为最有可能的问题。

中定义的搜索后缀/etc/resolv.conf将不起作用,因为它已被配置为服务器的 FQDN:

search server01.example.com
Run Code Online (Sandbox Code Playgroud)

有理由认为这些不起作用:

# nslookup server01
# nslookup client01
Run Code Online (Sandbox Code Playgroud)

上面的命令分别尝试解析server01.server01.example.comclient01.server01.example.com。这两个都不是有效名称。