- 安装软件:
yum -y install bind bind-utils
- 修改配置文件:
a. 修改主配置文件:vim /etc/named.confoptions { listen-on port 53 { 127.0.0.1;192.168.8.81; }; listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { lee; }; forwarders { 8.8.8.8;114.114.114.114; }; recursion yes; dnssec-enable yes; dnssec-validation yes; bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; }; acl lee { 192.168.8.0/24; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "lee.com" { type master; file "/etc/named/zones/lee.com.zone"; }; zone "168.192.in-addr.arpa" { type master; file "/etc/named/zones/192.168.zone"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
b. 创建正向解析域:vim /etc/named/zones/lee.com.zone
$TTL 1D @ IN SOA ns1.lee.com. admin.lee.com. ( 3 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) IN NS ns1.lee.com. ns1.lee.com. IN A 192.168.8.81 www.lee.com. IN A 192.168.8.81 blog.lee.com. IN A 192.168.8.82 shop.lee.com. IN A 192.168.8.83
c. 创建反向解析域:vim /etc/named/zones/192.168.zone
$TTL 1D @ IN SOA ns1.lee.com. admin.lee.com. ( 3 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) IN NS ns1.lee.com. 81.8 IN PTR ns1.lee.com. 81.8 IN PTR www.lee.com. 82.8 IN PTR blog.lee.com. 83.8 IN PTR shop.lee.com.
- 检查配置文件语法:
a. 检查主配置文件语法:named-checkconf
b. 检查正向解析域的语法:
named-checkzone lee.com /etc/named/zones/lee.com.zone
c. 检查反向解析域的语法:named-checkzone 192.168.in-addr.arpa /etc/named/zones/192.168.zone
- 启动服务:
systemctl start named
- 客户端验证:
a. linux客户端:
a-1. 修改DNS服务器:vim /etc/resolv.confnameserver 192.168.8.81
a-2. 验证:
b. windows客户端:
b-1. 修改DNS服务器:
b-2. 验证:
本文转自 Lee_吉 51CTO博客,原文链接:http://blog.51cto.com/12173069/2070037