站点图标 IDC铺

Linux 安装配置DNS服务器

VM虚拟的环境CENTOS 6.5 IP:192.168.1.170本地系统 IP:192.168.1.108一:安装DNSLinux安装DNS主要要安装2个程序:[root@tiejiang ~]# yum install bind*   //linux下 用于解析DNS的程序 [root@tiejiang ~]# yum install caching-nameserver   //这是另外一个软件

安装完成后,会发现/VAR/NAMED/下多出了几个文件证明安装好了二:配置DNS[root@tiejiang ~]# vim /etc/named.caching-nameserver.conf //以下为完整配置后的配置文件内容 // Provided by Red Hat caching-nameserver package to configure the // ISC BIND named(8) DNS server as a caching only nameserver // (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // // DO NOT EDIT THIS FILE – use system-config-bind or an editor // to create named.conf – edits to this file will be lost on // caching-nameserver package upgrade. // options { listen-on port 53 { 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”; // Those options should be used carefully because they disable port // randomization query-source port 53; // query-source-v6 port 53; allow-query { any; }; # allow-query-cache { any; }; }; logging { channel default_debug { file “data/named.run”; severity dynamic; }; }; view localhost_resolver { //解析器 match-clients { any; };//这里是允许那些地址用户使用本DNS进行解析 match-destinations { localhost; }; recursion yes; include “/etc/named.rfc1912.zones”; };。

[root@tiejiang ~]# vim /etc/named.rfc1912.zones //以下为完整配置后的配置文件内容: // named.rfc1912.zones: // // Provided by Red Hat caching-nameserver package // // ISC BIND named zone configuration for zones recommended by // RFC 1912 section 4.1 : localhost TLDs and address zones // // See /usr/share/doc/bind*/sample/ for example named configuration files. // zone “.” IN { type hint; file “named.ca”; }; zone “localdomain” IN { type master; file “localdomain.zone”; allow-update { none; }; }; 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; }; }; zone “0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa” IN { type master; file “named.ip6.local”; allow-update { none; }; }; zone “255.in-addr.arpa” IN { type master; file “named.broadcast”; allow-update { none; }; }; zone “0.in-addr.arpa” IN { type master; file “named.zero”; allow-update { none; }; }; //正向解析 zone “cintv.cn” IN { type master; file “cintv.cn.zone”; //正向解析的具体解析文件 allow-update { none; }; }; //反向解析 zone “1.168.192.in-addr.arpa” IN { type master; file “cintv.cn.local”; //反向解析的具体解析文件 allow-update { none; }; };

3。

配置在(2)中所需要用到的 正向、反向 具体解析文件

VI /var/named/cintv.cn.zone

新建向具体解析文件: VI /var/named/cintv.cn.zone (在其他的网上资料说,所有的操作文件应该在路径 /var/named/chroot/ 下的。

本人也看过了那些路径中的文件,不过最后本人顺利完成的情况就只在本文记录的路径下而且在那些路径下的以上提到的配置文件,都被我删除了因为我怕会有冲突影响没有做详细的实验研究,如果有读者清楚,望能告之如若以后本人有时间实验,也会更新上来。

内容如下:

$TTL 86400 //具体正向解析文件 @ IN SOA cintv.cn. root.cintv.cn ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS cintv.cn. dns IN A 192.168.1.170 www IN A 192.168.1.170 //单独解析主机名为www的地址 *.cintv.cn. IN A 192.168.1.170 //泛域名解析

VI /var/named/cintv.cn.local

新建向具体解析文件:VI /var/named/cintv.cn.local

内容如下:

$TTL 86400 @ IN SOA cintv.cn. root.cintv.cn. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS cintv.cn. 170 IN PTR www.cintv.cn. //在该IP段内哪个地址(170)解析到此域名 170 IN PTR dns.cintv.cn.

注意:无论正向还是反向的具体解析文件中,域名都是以英文符号“.”结尾的。

4。

修改 vi /etc/resolv.conf(配置本机适用什么DNS服务器的配置文件)

内容如下:

; generated by /sbin/dhclient-script search domain nameserver 192.168.1.170 //改为了本机刚刚配置的DNS服务器地址了 nameserver 192.168.1.170 //linux可以配置多个DNS服务器的,多少个我就不知道了,默认是2个,我都改了.

5。

重启DNS服务器 service named restart

三。

测试

在命令行输入 ping www.cintv.cn 。

成功的话就会解析到192.168.1.170.

后语:到此本人配置完成,在这里没少走弯路,都是因为网路上胡乱COPY的人弄的。

在此整理出来希望对大家有用

退出移动版