当前位置:Linux教程 - Linux - Unix编程/应用问答中文版 ---7.DNS相关问题

Unix编程/应用问答中文版 ---7.DNS相关问题

本文出自:http://www.nsfocus.com 维护:小四

7.1 如何进行DNS区传输
7.2 如何获知权威名字服务器
7.3 如何配置DNS的委托解析
7.4 如何获知BIND的版本号
7.5 Solaris/FreeBSD/Linux如何指定域名解析的顺序
--------------------------------------------------------------------------

7. DNS相关问题

7.1 如何进行DNS区传输

A: scz

用nslookup是最普遍适用的
nslookup
> server ns.tsinghua.edu.cn
> set type=axfr
> ls tsinghua.edu.cn [> tsinghua.txt] (方括号里的可选)

有些系统提供了dig命令
dig @ns.tsinghua.edu.cn axfr tsinghua.edu.cn

A: lgwu

有些系统提供了host命令,这个命令不太保险
host -l net.tsinghua.edu.cn (后面指定域)
host -l ncic.ac.cn

7.2 如何获知权威名字服务器

A: scz

nslookup
> set query=ns
> ncic.ac.cn (获知管辖该域的权威名字服务器)
Authoritative answers can be found from:
gatekeeper.ncic.ac.cn internet address = 159.226.41.188
> server gatekeeper.ncic.ac.cn
> set type=axfr (准备区传输)
> ls ncic.ac.cn > ncic.txt

7.3 如何配置DNS的委托解析

Q: 我想把子域DNS解析下放到下面去,在我这里如何配置

A: [email protected]

子域 IN NS <负责子域DNS解析的IP>

7.4 如何获知BIND的版本号

Q: 如何识别当前运行的bind是什么版本

A: M. Zuber

dig @ txt chaos version.bind

或者

nslookup
server
set query=txt
set class=chaos
version.bind

但是这个返回结果可以通过/etc/named.conf自己设置,并不可靠。如果你正在运
行BIND 8,可以执行

/usr/sbin/ndc status

A: backend

#!/bin/sh
# bv (Bind Version) script
# written by [email protected]

USAGE=""Usage: $0
""

if [ $# -ne 1 ]; then
echo $USAGE
exit
fi

if [ ! -f /usr/bin/dig ]; then
echo -en ""Can''t find ""dig"" program. ""
exit
fi

VER=``/usr/bin/dig @$1 version.bind chaos txt | grep ""VERSION.BIND""``

if [ ""x$VER"" = ""x"" ]; then
echo -en ""Sorry. Can''t get BIND version. ""
else
echo -en ""BIND version of $1 = ""
echo -en """"
echo $VER | awk ''{print $5;}''

echo -en "" ""
fi

A: deepin

很多主机没有dig,最方便的办法是
nslookup -q=txt -class=chaos version.bind IP-addr
如果要美观一点,所以可以用这样的一个小脚本

#!/bin/sh
if [ $# = 0 ];then echo ""useage: $0 IP-Addr.""; exit 1;fi
VER=``nslookup -q=txt -class=chaos version.bind $1 | grep ""VERSION.BIND""``
if [ $? = 0 ];then
echo -en ""BIND version of $1 = "" ``echo $VER | awk
''{print $4,$5,$6;}''`` "" ""
else
echo -en ""Sorry. Can''t get BIND version. ""
fi

命令行上直接指定IP,会进行反向域名解析,有可能失败,进入nslookup之后server
指定IP,则无此问题。

7.5 Solaris/FreeBSD/Linux如何指定域名解析的顺序

Q: 如何在Solaris中使/etc/resolv.conf的设置生效

A: cp /etc/nsswitch.dns /etc/nsswitch.conf
或者
vi /etc/nsswitch.conf

hosts: files dns

Q: FreeBSD中有类似Solaris的/etc/nsswitch.conf的文件吗

A: /etc/host.conf

--------------------------------------------------------------------------
# First try the /etc/hosts file
hosts
# Now try the nameserver next.
# 如果不希望做反向域名解析,则注释掉下面这行
# bind
# If you have YP/NIS configured, uncomment the next line
# nis
--------------------------------------------------------------------------

Q: Linux中有类似Solaris的/etc/nsswitch.conf的文件吗

D: /etc/host.conf

--------------------------------------------------------------------------
order hosts, bind, nis
multi on
--------------------------------------------------------------------------

D: rai@SMTH Unix 2001-11-28 09:42

改了/etc/host.conf还是不行,后来试了一下/etc/nsswitch.conf就可以了,Linux
也有这个文件的,必须保证下一行中有dns

--------------------------------------------------------------------------
# hosts: db files nisplus nis dns
hosts: files nisplus nis dns
--------------------------------------------------------------------------