查看文章 |
master配置 1、编辑/etc/named.conf文件成如下形式: options{ directory "/var/named"; allow-query{192.168.1.0/24}; 指定允许进行域名解析的主机 }; zone "." IN{ 定义根域 type hint; file "named.ca"; }; zone "localhost" IN{ 定义正向解析域 type master; file "localhost.zone"; allow-update{none;}; }; zone "0.0.127.in-addr.arpa" IN{ 定义反向解析域 type master; file "named.local"; allow-update{none;}; }; 2、启动Bind9 #service named start 客户端配置 编辑/etc/resolv.conf,将DNS服务器加入 nameserver 192.168.1.1 nameserver 192.168.1.2 用nslookup测试 #nslookup >www.sina.com.cn
1、编辑/etc/named.conf,添加如下内容: zone "ncie.org"{ type master; file "named.ncie.org"; }; zone "1.168.192.in-addr.arpa."{ type master; file "named.192.168.1"; }; 2、编辑ncie.org区域的区数据库配置文件/var/named/named.ncie.org,内容如下: $TTL 300 @ SOA ns1.ncie.org. root.ns1.ncie.org.( 2003053013;serial 3600;refresh 900;retry 1209600;expire 3600;minimum ) @ IN NS ns1 ns1 IN A 192.168.1.1 www IN CNAME ns1 host2 IN A 192.168.1.2 host3 IN A 192.168.1.3 host4 IN A 192.168.1.4 3、编辑1.168.192.in-addr.arpa区域的配置文件/var/named/named.192.168.1,内容如下: $TTL 300 @ SOA ns1.ncie.org. root.ns1.ncie.org.( 2003053013;serial 3600;refresh 900;retry 1209600;expire 3600;minimum ) @ IN NS ns1.ncie.org. 1 IN PTR ns1.ncie.org. 2 IN PTR host2.ncie.org. 3 IN PTR host3.ncie.org. 4 IN PTR host4.ncie.org. 4、重启Bind9 #service named restart 客户端配置 编辑/etc/resolv.conf,加入默认搜索域和域名服务器,内容如下 domain ncie.org search ncie.org nameserver 192.168.1.1 用nslookup测试 #nslookup >set all 查询所有类型 >host4 >www.sina.com.cn > >set type=ANY 查询更详细的信息 >www.sina.com.cn > >server ns1.sina.com.cn. 登录到域外的主机执行命令 >www.sina.com.cn > >server ns1.ncie.org. >set type=PTR >192.168.1.4 > >set type=CNAME >www.ncie.org >exit 配置辅域名服务器 1、在局域网内的另一台服务器上安装Bind9 2、编辑此服务器上的/etc/named.conf,内容如下: zone "ncie.org"{ type slave; file "named.ncie.org"; masters{192.168.1.1;}; }; zone "1.168.192.in-addr.arpa."{ type slave: file "named.192.168.1"; masters{192.168.1.1;}; }; 3、编辑主域名服务器上的/etc/named.conf文件,在options区段加入如下行,设置允许辅域名服务器从主域名服务器同步区域数据库 allow-transfer{192.168.1.2;}; 4、启动辅域名服务器: service named start 5、登录客户机测试 #nslookup >server 192.168.1.2 >host4.ncie.org
实验步骤: 1、编辑主域名服务器中的ncie.org区域配置文件named.ncie.org,在其中添加如下内容,为区域lab.ncie.org设置主域名服务器和辅域名服务器。 ns2 IN A 192.168.1.101 ns3 IN A 192.168.1.102 lab.ncie.org. IN NS ns2.ncie.org. lab.ncie.org. IN NS ns3.ncie.org. 2、再分别到两台接受委派的机器上建立A记录,以下以192.168.1.101机器为例 ns1 IN A 192.168.1.102 @ IN NS ns1.lab.ncie.org 3、service named restart 4、客户机测试:(将客户端的DNS指向ns1.ncie.org) #nslookup >server ns1.ncie.org. >set type=NS >lab.ncie.org.
附注:适合DNS服务器的iptables配置 #!/bin/bash iptables -P INPUT DROP iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT |

