1,首先需要安装Bind,
yum install bind*
yum install caching-nameserver
2,编辑 named.conf 文件,
cd /var/named/chroot/etc
cp -p named.caching-nameserver.conf named.conf
注:使用cp -p 参数在复制的时候文件的属性不会改变。如果直接 cp 则要修改此文件的属性
chown :named named.confvim named.conf
options {
listen-on port 53 { 127.0.0.1; }; //127.0.0.1 改为 any
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";
query-source port 53;
query-source-v6 port 53;
allow-query { any; }; //localhost 改为 any
forwarders { 202.102.128.68; }; // 此行默认没有,如果内网使用此dns 服务器可以设置 dns 转发,这里一定是一个有效的 dns 服务器地址,则添加这两行 。
forward only;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; }; //localhost 改为 any
match-destinations { any; }; //localhost 改为 any
recursion yes;
include "/etc/named.rfc1912.zones";
};
3,编辑 /var/named/chroot/etc/named.rfc1912.zones
cd /var/named/chroot/etc
vi named.rfc1912.zones //dns 服务器的区域主配置文件
在最后添加自己的 dns 区域 如果有多个则类似添加
zone "usoftcore.org" IN { // usoftcore.org 我实验用的区域,正向解析区域
type master;
file "usoftcore.org.zone"; // usoftcore.org.zone本区域的配置文件
allow-update { none; };
};
zone "59.168.192.in-addr.arpa" IN { //192.168.59.* 反向解析区域
type master;
file "59.168.192.zone"; // 192.168.59.* 反向解析区域配置文件
allow-update { none; };
};
4,设置域配置文件,
cd /var/named/chroot/var/named/
cp -p localdomain.zone usoftcore.org.zone
cp -p named.local 59.168.192.zonevi 1.168.192.zone
$TTL 86400
@ IN SOA localhost. root.localhost. (
2010082400 ; Serial // yyyymmddxx 做序列号
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS smilonet.org.
30 IN PTR dns.usoftcore.org. // 我的dnsserver ip为192.168.59.30,所以前面是30
31 IN PTR www.usoftcore.org.vi smilonet.org.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS dns //添加域名服务器记录-NS记录(设置当前域的DNS服务器名称)
// IN MX 5 mail //添加邮件交换记录-MX记录(设置mail.annexmicro.com主机作为邮件服务器)
dns IN A 192.168.59.30 //添加正向解析
www IN A 192.168.59.31
5,添加新的DNS服务器,
vi /etc/resolv.conf
nameserver 192.168.59.30
6,设置服务及防火墙,
setup
开启named 服务添加tcp:53 udp:53 为端口通过条件
7,测试:
nslookup
>dns.usoftcore.org