Dns的安装

 

(当没有安装chroot时   dns配置文件在/etc/named.conf下),安装后的dns配置文件在/var/named/chroot/etc/

 

[root@localhost Server]# cd /var/named/chroot/etc/

[root@localhost etc]# vim named.conf   (主配置文件)

 

options {                                       设置正反解的配置文件目录

        directory "/var/named";

        };

zone "xiaoxiang.com"{                            设置正解的域名

         type      master;                      类型(为主)

         file      "xiaoxiang.com.zone";             配置的文件名

                    };

zone "18.168.192.in-addr.arpa"{                          设置反解的

          type     master;

          file     "xiaoxiang.com.192.168.18";

                               };

 

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.zone    (正解的文件编辑)

 

$TTL    86400                                                     (定义向外查询的数据记录在dnscache当中多久 , 单位秒)

@                   IN SOA  loclhost root (                           (named.conf zone定义的, SOA 为开始设定内容的意思)

                                          42     ;serial(d.adams)    (与masterslave是否同步有关,数值变大,slave会同步更新)

                                          3H     ;refresh            (定义slave同步多久会主动检查serial的值,以便更新)

                                          15M    ;retry              (定义slave没有连接上master DNS,则多久后重新检查)

                                          1W     ;expiry             (如果没有连上,到了设置的时间slave就会放弃检查,不再更新)

                                          1D     ;minimum           (就是TTL,如果没有定义TTL,可以这个设定)

                                          ) 

xiaoxiang.com.     IN NS    www.xiaoxiang.com.                           (设置正解的信息内容)

www                IN   A   192.168.18.186                           (A为正解里hostname对应ip的标志)

 

 

 

 

 

 

 

编辑反解的配置文件

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.192.168.1

 

$TTL   86400

@                    IN SOA   localhost root (

                                             42    ;serial(d.adams)

                                             3H    ;refresh

                                             15M   ;retry

                                             1W    ;expiry 

                                             1D)   ;minimum

                     IN NS    www.xiaoxiang.com.

186                  IN PTR   www.xiaoxiang.com.            (PTR 为反解的标志)

 

启动

[root@localhost etc]# /etc/init.d/named start

启动 named:                                               [确定]

[root@localhost etc]# host www.xiaoxiang.com 

www.xiaoxiang.com has address 192.168.18.186

[root@localhost etc]# host 192.168.18.186

186.18.168.192.in-addr.arpa domain name pointer www.xiaoxiang.com.

 

测试: 客户端dns设置为192.168.18.186

 

配置完成!

 

配置主辅DNS

 

主:

[root@localhost etc]# vim named.conf

options {

        directory "/var/named";

        };

zone "xiaoxiang.com"{

         type      master;

         file      "xiaoxiang.com.zone";

         allow-transfer {192.168.18.196;};

                    };

zone "18.168.192.in-addr.arpa"{

          type     master;

          file     "xiaoxiang.com.192.168.18";

          allow-transfer {192.168.18.196;};

                               };

 

 

 

 

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.192.168.18

$TTL   86400

@                    IN SOA   localhost root (

                                             42    ;serial(d.adams)

                                             3H    ;refresh

                                             15M   ;retry

                                             1W    ;expiry 

                                             1D)   ;minimum

                     IN NS    www.xiaoxiang.com.

186                  IN PTR   www.xiaoxiang.com.

 

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.zone

$TTL    86400

@                   IN SOA  loclhost root (

                                          42     ;serial(d.adams)

                                          3H     ;refresh

                                          15M    ;retry

                                          1W     ;expiry

                                          1D     ;minimum

                                          ) 

xiaoxiang.com.     IN NS    www.xiaoxiang.com.

www                IN   A   192.168.18.186

 

辅配置

[root@localhost etc]# vim named.conf

options {

         directory "/var/named";

        };

zone "xiaoxiang.com"{

      type       slave;

      file       "xiaoxiang.com.zone";

      masters { 192.168.18.186;};

              };

zone   "18.168.192.in-addr.arpa"{

       type       slave;

       file          "xiaoxiang.com.192.168.18";

       masters { 192.168.18.186;};

               }

 

 

 

 

 

 

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.192.168.18

$TTL   86400

@                    IN SOA   localhost root (

                                             42    ;serial(d.adams)

                                             3H    ;refresh

                                             15M   ;retry

                                             1W    ;expiry

                                             1D)   ;minimum

                     IN NS    www.xiaoxiang.com.

186                  IN PTR   www.xiaoxiang.com.

 

[root@localhost etc]# vim /var/named/chroot/var/named/xiaoxiang.com.zone

$TTL    86400

@                   IN SOA  loclhost root (

                                          42     ;serial(d.adams)

                                          3H     ;refresh

                                          15M    ;retry

                                          1W     ;expiry

                                          1D     ;minimum

                                          )

xiaoxiang.com.     IN NS    www.xiaoxiang.com.

www                IN   A   192.168.18.186

启动/etc/init.d/named.conf

[root@localhost var]# chmod 777 named        (改named权限)

客户端测试:将dns设置为196,后ping

 

配置成功

 

转发服务器的配置

[root@localhost etc]# vim named.conf 

options {

         directory "/var/named";        【指定配置目录(在dns上,转发上不用配置)】

         recursion yes;             

         allow-query     { any; };

         allow-query-cache { any; };

 forwarders {192.168.18.186;};

         forward only;                   (只允许forward

        };

/etc/init.d/named start

测试:客户端dns改为转发的ipping域名

 

配置成功!