分类: 系统运维
2015-08-14 16:19:37
搭建一个dns服务器
安装dns包:
[root@super63 ~]# rpm -ivh
/mnt/Packages/bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
[root@super63 ~]# rpm -ivh
/mnt/Packages/bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
[root@super63 ~]# rpm -ivh
/mnt/Packages/bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
重启dns后配置文件自动挂载:
[root@super63 ~]# service named restart
[root@super63 ~]# ls
/var/named/chroot/etc/named/
配置DNS服务器解析:super.cn
修改配置文件:
[root@super63 ~]# vim /var/named/chroot/etc/named.conf
ptions {
listen-on port 53 { any; };
listen-on-v6 port 53 { any; };
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 { any; };
recursion yes;
zone "super.cn"
IN {
type master;
file "super.cn.zone";
创建zone文件:
[root@super63 ~]# cd
/var/named/chroot/var/named/
[root@super63 named]# cp -p named.localhost
super.cn.zone # 注意权限
编辑zone文件:
[root@super63 named]# vim super.cn.zone
$TTL 1D
super.cn. IN SOA
dns.super.cn. root.super.cn. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H
) ; minimum
super.cn. NS
dns.super.cn.
dns.super.cn. A
192.168.1.63
A
192.168.1.63
检查zone文件
[root@super63 named]# named-checkzone
"super.cn" super.cn.zone
zone super.cn/IN: loaded serial 0
OK
重启dns服务器:
[root@super63 ~]# service named restart
Stopping named: .
[ OK ]
Starting named:
[ OK ]
更改本机使用的dns服务器:
[root@super63 ~]# vim
/etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=192.168.1.63
重启网络:
[root@super63 ~]# service network restart
测试:
[root@super63 ~]# ping
PING (112.124.54.19) 56(84)
bytes of data.
64 bytes from 112.124.54.19: icmp_seq=1
ttl=49 time=36.4 ms