智能DNS

智能DNS:
    根据客户端来源IP的地址,来为某一个解析请求返回一个设定好的解析结果

view将同一种应用对不同的用户呈现出不同的结果
    任何时候,使用了view,所有的zone都必须在view中
#service named stop
#ls
#vim /etc/named.conf
options {
         directory "/var/named";         
        
};
 
view localnet {
   match-clients { 192.168.0.0/24; };   对来源网络进行匹配
   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";
   };
};

view external {              声明一个外部网络
    match-clients { 172.16.0.0/16; };
    zone "magedu.com" IN {
         type master;
         file "magedu.com.external";
   };
};

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

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
};   
#named-checkconf
#cd /var/named/
#ls
#vim magedu.com.zone
$TTL 600
$ORIGIN magedu.com.
@        IN          SOA         ns1.magedu.com. (
                      2011112402
                      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.100.1      
pop3      IN     A           192.168.0.254
ftp       IN          A           192.168.0.254

tech.magedu.com.        IN         NS       ns.tech.magedu.com
ns.tech.magedu.com.     IN         A        192.168.0.183
market.magedu.com.      IN         NS       ns.market.magedu.com
ns.market.magedu.com.   IN         A        192.168.0.184
#cp magedu.com.zone magedu.com.external
#vim magedu.com.external

$TTL 600
$ORIGIN magedu.com.
@        IN          SOA         ns1.magedu.com. (
                      2011112402
                      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           172.16.0.254
mail2     IN          A           172.16.0.1
www       IN          A           172.16.100.1      
pop3      IN     A           172.16.0.254
ftp       IN          A           172.16.0.254

tech.magedu.com.        IN         NS       ns.tech.magedu.com
ns.tech.magedu.com.     IN         A        192.168.0.183
market.magedu.com.      IN         NS       ns.market.magedu.com
ns.market.magedu.com.   IN         A        192.168.0.184
#service named restart
#tail /var/log/messages   报错,magedu.com.external没权限
#ll
#chgrp named magedu.com.external
#ll
#!se                     调用最近一次的se开头的命令                     

#!ta                      调用最近一次的ta开头的命令

之后就是测试了
再加一个view,用来解释其他网络传过来的地址
#vim /etc/named.conf
options {
         directory "/var/named";         
        
};
 
view localnet {
   match-clients { 192.168.0.0/24; };   对来源网络进行匹配
   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";
   };
};

view external {              声明一个外部网络
    match-clients { 172.16.0.0/16; };
    zone "magedu.com" IN {
         type master;
         file "magedu.com.external";
   };
};

view unknownet {              声明一个外部网络
    match-clients { any; };
    zone "magedu.com" IN {
         type master;
         file "magedu.com.any";
   };
};

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

contorls {
         inet 127.0.0.1 port 953
                  allow { 127.0.0.1; } keys { "rndckey"; };
}; 
#cp magedu.com.zone magedu.com.any
#vim magedu.com.any 

$TTL 600
$ORIGIN magedu.com.
@        IN          SOA         ns1.magedu.com. (
                      2011112402
                      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           172.16.100.1     
#rndc reload
#rndc status
#chgrp named magedu.com.any

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章