配置主从域名服务器

现在来做主从域名服务器:
Master:192.168.0.181/24,ns1.magedu.com
Slave:192.168.0.182/24,ns2.magedu.com
Domain:magedu.com
希望实现在里面添加几条记录:
www
ftp
mail
mail2
pop3
www2  别名


在MASTER上配置:

#hostname ns1.magedu.com
#vim /etc/sysconfig/network
#getenforce   把selinux关掉
#setenforce 0  
#cd /etc/yum.repos.d/              配置本地yum源,安装软件包
#vim server.repo
#dig -t A instructor.example.com
#cat /etc/resolv.conf
#yum list bind*                    查看bind软件包
#yum install bind
#cd       
#rndc
#ls /etc | grep rndc                                  生成rndc
#cat /etc/rndc/key                      
#rndc-confgen > /etc/rndc/conf
#cat !$
#vim /etc/named.conf
options {
         directory "/var/named";
         querylog yes;
         version "None of your business.";
};
 
zone "." IN {
         type hint;
         file "named.ca";
};

zone "localhost" IN {
         type master;
         file "localhost.zone";
};    

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.loacal";
};

key "rndckey" {
         algorithm hmac-md5;
         secret "uAgAJYS+FB3xvAWoVxctGQ==";
};

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};
#ll !$     查看到所有用户都拥有读权限
#chmod o-r !$     把读权限取消
#chgrp named !$    属组改为named
#ll /etc/named.conf
#cd /var/named/
#ls
#dig -t NS .              获取根的NS记录
#dig -t NS . > /var/named/named.ca
#vim localhost.zone
$TTL 43200
@        IN             SOA         localhost.      root (
                        2011112401
                        3h
                        30M
                        2W
                        1H )
                   IN            NS          localhost.  
localhost.         IN            A           127.0.0.1

#cp localhost.zone named.local               开始编辑反向
#vim !$
$TTL 43200
@        IN             SOA         localhost.      root (
                        2011112401
                        3h
                        30M
                        2W
                        1H )
                   IN            NS          localhost.  
1                  IN            PTR         localhost.
#ll
#chown :named localhost.zone named.*
#ll
#named-checkconf                 检查语法错误
#named-checkzone "localhost" localhost.zone
#named-checkzone "0.0.127.in-addr.arpa" named.local
#service named start
#tail /var/log/messages          查看日志
#netstat -tunlp | grep "53$"
#netstat -tunlp | grep ":53\>"
#rndc status
#rndc reload
#vim /etc/named.conf               配置正向解析  
options {
         directory "/var/named";
         querylog yes;
         version "None of your business.";
};
 
zone "." IN {
         type hint;
         file "named.ca";
};

zone "localhost" IN {
         type master;
         file "localhost.zone";
};    

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.loacal";
};

zone "magedu.com" IN {
         type master;
         file "magedu.com.zone";
};

key "rndckey" {
         algorithm hmac-md5;
         secret "uAgAJYS+FB3xvAWoVxctGQ==";
};

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};
#cd /var/named/    
#ls
#vim magedu.com.zone                               
$TTL 600
$ORIGIN magedu.com.
@        IN          SOA         ns1.magedu.com. (
                      2011112401
                      1H
                      10M
                      7D
                      1H )
          IN          NS          ns1
          IN          NS          ns2
          IN          MX       10 mail
          IN          MX       20 mail2
ns1       IN          A           192.168.0.181
ns2       IN          A           192.168.0.182
mail      IN          A           192.168.0.254
mail2     IN          A           192.168.0.1
www       IN          A           192.168.0.1
www       IN          A           192.168.0.2         实现负载均衡
pop3      IN     A           192.168.0.254
ftp       IN          A           192.168.0.254
www2      IN          CNAME       www
#named-checkzone "magedu.com" magedu.com.zone
#cat /etc/named.conf
#rndc reload
#rndc status
#dig -t NS magedu.com
#dig -t MX magedu.com
#dig -t A www.magedu.com
#dig -t CNAME www2.magedu.com
#host -t A www.magedu.com
#vim /etc/named,conf                     实现反向解析
options {
         directory "/var/named";
         querylog yes;
         version "None of your business.";
};
 
zone "." IN {
         type hint;
         file "named.ca";
};

zone "localhost" IN {
         type master;
         file "localhost.zone";
};    

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.loacal";
};

zone "magedu.com" IN {
         type master;
         file "magedu.com.zone";
};

zone "0.168.192.in-addr.arpa" IN {
         type master;
         file "192.168.0.zone";
};

key "rndckey" {
         algorithm hmac-md5;
         secret "uAgAJYS+FB3xvAWoVxctGQ==";
};

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};
#ls
#cp magedu.com.zone 192.168.0.zone
#vim !$
$TTL 600
@        IN          SOA         ns1.magedu.com. (
                      2011112401
                      1H
                      10M
                      7D
                      1H )
          IN          NS            ns1.magedu.com.
          IN          NS            ns2.magedu.com.
181       IN          PTR           ns1.magedu.com.
182       IN          PTR           ns2.magedu.com.
254       IN          PTR           mail.magedu.com.
1         IN          PTR           mail2.magedu.com.
1         IN          PTR           www.magedu.com.
2         IN          PTR           www.magedu.com.        实现负载均衡
254       IN     PTR           pop3.magedu.com.
254       IN          PTR           ftp.magedu.com.
#rndc reload
#rndc status
#dig -x 192.168.0.181
#chkconfig --list named    确定配置的服务,开机自动启动
#chkconfig named on        把配置的服务打开
#chkconfig --list named
#ll
#chmod o-r 192.168.0.zone magedu.com.zone  
#ll
#chmod :named magedu.com.zone 192.168.0.zone    把这两个的权限改为named
#ll

在SLAVE上配置:

#hostname ns2.magedu.com
#vim /etc/sysconfig/network    主机名永久生效
#dig -t A instructor.example.com
#yum install bind
#rndc-confgen > /etc/rndc.conf
#cat !$
#vim /etc/named.conf
options {
         directory "/var/named";
};
 
zone "." IN {
         type hint;
         file "named.ca";
};

zone "localhost" IN {
         type master;
         file "localhost.zone";
};    

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.loacal";
};

key "rndckey" {
         algorithm hmac-md5;
         secret "4HkEGKVmpXQKwIN3214PVQ==";
};

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};
#chmod o-r !$                     改权限,改属组
#chown :named !$
#ll /etc/named.conf
#cd /var/named/
#ls                                               把/var/named/named.ca
#scp -p 192.168.0.181:/var/named/named.ca ./      复制到当前目录
#ll
#scp -p 192.168.0.181:/var/named/named.local ./
#scp -p 192.168.0.181:/var/named/localhost.zone ./
#chmod o-r localhost.zone named.*
#ll
#chown :named localhost.zone named.*
#ll
#service named start
#chkconfig named on
#tail /var/log/massages
#rndc status
#dig -t AXFR magedu.com
#dig -t AXFR magedu.com @192.168.0.181    查看正向区域传送是否正常
#dig -t AXFR 0.168.192.in-addr.arpa @192.168.0.181  查看反向区域
#vim /etc/named.conf            直接正反两种解析一起配置
options {
         directory "/var/named";
};
 
zone "." IN {
         type hint;
         file "named.ca";
};

zone "localhost" IN {
         type master;
         file "localhost.zone";
};    

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.loacal";
};

zone "magedu.com" IN {
         type slave;
         file "slaves/magedu.com.zone";
         masters { 192.168.0.181; };
};

zone "0.168.192.in-addr.arpa" IN {
         type slave;
         file "slaves/192.168.0.zone";
         masters { 192.168.0.181; };
};

key "rndckey" {
         algorithm hmac-md5;
         secret "4HkEGKVmpXQKwIN3214PVQ==";
};

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};              
#named-checkconf
#rndc reload
#tail /var/log/messages
#ll slaves/
#vim /etc/resolv.conf       本地解析,服务器指向本机地址
#dig -t NS magedu.com
#cat slaves/magedu.com.zone

你可能感兴趣的:(NetWork,记录,休闲,软件包,域名服务器)