Linux 的DNS 的配置…

Linux 的DNS 的配置…

Linux DNS 的配置

#安装和检查BIND域名服务器:
[root@sql root]# rpm -qa|grep bind

bind-9.2.1-16

redhat-config-bind-1.9.0-13

bind-utils-9.2.1-16

ypbind-1.11-4

[root@sql root]# rpm -qa|grep name

caching-nameserver-7.2-7

以上是检查到BIND在本机的安装情况和得到的信息,如果未安装,按以下步骤:

[root@redhatlinux9 root]# mount /mnt/cdrom/
挂载光驱,需要安装光盘第一张。

[root@redhatlinux9 root]# cd /mnt/cdrom/RedHat/RPMS/
进入光盘中RPM包所在路径。

[root@redhatlinux9 RPMS]# rpm -ivh bind-9.2.1-16.i386.rpm
[root@redhatlinux9 RPMS]# rpm -ivh bind-utils-9.2.1-16.i386.rpm
[root@redhatlinux9 RPMS]# rpm -ivh redhat-config-bind-1.9.0-13.norach.rpm
安装以上三个RPM包。

[root@redhatlinux9 RPMS]# cd; umount /mnt/cdrom/
卸载光驱挂载,放入第二张安装光盘。

[root@redhatlinux9 root]# mount /mnt/cdrom/
挂载光驱,需要第二张安装光盘。

[root@redhatlinux9 root]# cd /mnt/cdrom/RedHat/RPMS/
进入RPM包所在路径。

[root@redhatlinux9 RPMS]# rpm -ivh caching-nameserver-7.2-7.noarch.rpm
安装此RPM包。

以下启动BIND服务:
[root@redhatlinux9 RPMS]# service named start
立即启动BIND服务,成功。

[root@redhatlinux9 RPMS]# pstree|grep named
     |-named
检查服务运行,可以看到NAMED服务正在运行。

[root@redhatlinux9 RPMS]# rndc status
number of zones: 4
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
server is up and running
以上是查看服务器运行状态的命令和得到的信息。

#一:配置主域名服务器

vi /etc/named.conf

// generated by named-bootconf.pl

options {

directory “/var/named”;

/*

* If there is a firewall between you and nameservers you want

* to talk to, you might need to uncomment the query-source

* directive below. Previous versions of BIND always asked

* questions using port 53, but BIND 8.1 uses an unprivileged

* port by default.

*/

// query-source address * port 53;

};

//

// a caching only nameserver config

//

controls {

inet 127.0.0.1 allow { localhost; } keys { rndckey; };

};

zone “.” IN {

type hint;

file “named.ca”;

};

zone “localhost” IN {

type master;

file “localhost.zone”;

allow-update { none; };

};

zone “0.0.127.in-addr.arpa” IN {

type master;

file “named.local”;

allow-update { none; };

};

zone “sql.dba.com” IN {

type master;

file “dba.com.zone”;

allow-update { none; };

};

zone “6.168.192.in-addr.arpa” IN {

type master;

file “dba.com.revl.zone”;

allow-update { none; };

};

include “/etc/rndc.key”;

编辑正向解析配置文件

vi /var/named/dba.com.zone

$TTL 86400

$ORIGIN sql.dba.com.

@ 1D IN SOA sql.dba.com. root (

42 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

1D IN NS sql.dba.com

1D IN A 192.168.6.1

~

编辑反向解析配置文件

vi /var/named/dba.com.revl.zone

$TTL 86400

@ IN SOA sql.dba.com. root.sql.dba.com. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

IN NS sql.dba.com

1 IN PTR sql.dba.com.

文件配置好之后一定要重新启动服务使其生效。

[root@sql root]# service named restart

Stopping named:

或者使用此命令,其作用也使重新加载服务

[root@sql root]# rndc reload

#验证DNS

[root@sql root]# cat /etc/resolv.conf

nameserver 192.168.6.1

如果没有,用

[root@sql root]# vi /etc/resolv.conf

nameserver 192.168.6.1

#一:HOST命令

正向查询主机地址。

[root@sql root]# host sql.dba.com

sql.dba.com has address 192.168.6.1

反向查询域名

[root@sql root]# host 192.168.6.1

1.6.168.192.in-addr.arpa domain name pointer sql.dba.com.

查询不同类型的资源记录配置

[root@sql root]# host -t NS sql.dba.com

sql.dba.com name server sql.dba.com.sql.dba.com.

[root@sql root]# host -t SOA sql.dba.com

sql.dba.com SOA sql.dba.com. root.sql.dba.com. 42 10800 900 604800 86400

[root@sql root]# host -t MX sql.dba.com

列出整个域信息

[root@sql root]# host -l sql.dba.com

sql.dba.com SOA sql.dba.com. root.sql.dba.com. 42 10800 900 604800 86400

sql.dba.com name server sql.dba.com.sql.dba.com.

sql.dba.com has address 192.168.6.1

sql.dba.com SOA sql.dba.com. root.sql.dba.com. 42 10800 900 604800 86400

[root@sql root]#

列出与一个主机名相关的资源记录的详细信息。

[root@sql root]# host -a sql.dba.com

Trying “sql.dba.com”

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20623

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:

;sql.dba.com. IN ANY

;; ANSWER SECTION:

sql.dba.com. 86400 IN SOA sql.dba.com. root.sql.dba.com. 42 10800 900 604800 86400

sql.dba.com. 86400 IN NS sql.dba.com.sql.dba.com.

sql.dba.com. 86400 IN A 192.168.6.1

Received 112 bytes from 192.168.6.1#53 in 1 ms

[root@sql root]#

#二:NSLOOKUP命令

[root@sql root]# nslookup

Note: nslookup is deprecated and may be removed from future releases.

Consider using the `dig’ or `host’ programs instead. Run nslookup with

the `-sil[ent]’ option to prevent this message from appearing.

> sql.dba.com

Server: 192.168.6.1

Address: 192.168.6.1#53

Name: sql.dba.com

Address: 192.168.6.1

> 192.168.6.1

Server: 192.168.6.1

Address: 192.168.6.1#53

1.6.168.192.in-addr.arpa name = sql.dba.com.

> see all

[root@sql root]# nslookup

Note: nslookup is deprecated and may be removed from future releases.

Consider using the `dig’ or `host’ programs instead. Run nslookup with

the `-sil[ent]’ option to prevent this message from appearing.

> sql.dba.com

Server: 192.168.6.1

Address: 192.168.6.1#53

Name: sql.dba.com

Address: 192.168.6.1

> 192.168.6.1

Server: 192.168.6.1

Address: 192.168.6.1#53

1.6.168.192.in-addr.arpa name = sql.dba.com.

> set all

Default server: 192.168.6.1

Address: 192.168.6.1#53

Set options:

novc nodebug nod2

search recurse

timeout = 0 retry = 2 port = 53

querytype = A class = IN

srchlist =

> set type = any

*** Invalid option: type

> set type=any

> sql.dba.com

Server: 192.168.6.1

Address: 192.168.6.1#53

sql.dba.com

origin = sql.dba.com

mail addr = root.sql.dba.com

serial = 42

refresh = 10800

retry = 900

expire = 604800

minimum = 86400

sql.dba.com nameserver = sql.dba.com.sql.dba.com.

Name: sql.dba.com

Address: 192.168.6.1


Leave a Comment