1. 程式人生 > 實用技巧 >2020/11/24

2020/11/24

搭建主DNS伺服器,要求如下:該DNS伺服器能解析www.qq.com和www.163.com的IP地址,發給qq.com域的郵件都會優先發給mail.qq.com,當mail.qq.com無法收下郵件時則郵件會發送給mail2.qq.com,發給163.com域的郵件都會發給mail.163.com。

1.裝包

yum -y install bind
yum install bind-utils -y

2.寫配置檔案

vim /etc/named.conf
options {
          listen-on port 53 { 192.168.124.128; };
           directory       "/var/named";
   };      
   zone "qq.com" IN {
           type master;
           file "named.qq.com";
   };      
   zone "163.com" IN {
          type master;
          file "named.163.com";
  };

3.編輯解析檔案

vim /var/named/named.qq.com
$TTL 1D
@       IN      SOA     master.qq.com.  admin.qq.com.(
                                        0
                                        1D
                                        1H
                                        1W
                                        3H)
        IN      NS      master.qq.com.
        IN      MX      5 mail.qq.com.
        IN      MX      8 mail2.qq.com.
master  IN      A       192.168.124.128
mail    IN      A       192.168.124.128
mail2   IN      A       192.168.124.138
www     IN      A       192.168.124.128
vim /var/named/named.163.com
$TTL 1D
@       IN      SOA     master.163.com. admin.163.com.(
                                        0
                                        1D
                                        1H
                                        1W
                                        3H)
        IN      NS      master.163.com.
        IN      MX      5 mail.163.com.
master  IN      A       192.168.124.128
mail    IN      A       192.168.124.128
www     IN      A       192.168.124.136


4.重啟named服務

systemctl restart named

5.解析

host www.qq.com 192.168.124.128
host www.163.com 192.168.124.128