RedHat5搭建简单DNS服务器

服务安装

  • yum install bind
  • yum install bind-chroot
  • yum install caching-nameserver-9.3.4-6.P1.el5.i386.rpm  //dns配置文件模版

搭建目标

  • DNS服务主机IP:192.168.1.150
  • DNS服务存储网站目录
  • www.abc.test1 正向解释 192.168.1.151
  • 192.168.1.151 反向解释 www.abc.test1

DNS全局配置文件

  • 启动DNS服务
  • service named start
  • vi /var/named/chroot/etc/named.caching-nameserver.conf
//
// 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; };  //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; };   //any
};


logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};


view localhost_resolver {
match-clients     { localhost; };
match-destinations { localhost; };
recursion yes;
include "/etc/named.rfc1912.zones";
};

DNS区域配置文件

vi /var/named/chroot/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 "abc.test1" IN {
type master;
file "abc.test1.zone";
allow-update {none;};
};


zone "1.168.192.in-addr.arpa" IN {
type master;
file "192.168.1.local";
allow-update {none;};
};

创建DNS域名文件

  • cd /var/named/chroot/var/named
  • cp -a localhost.zone abc.test1.zone  
  • cp -a named.local 192.168.1.local  //cp命令的时候,谨记带上参数-a,因为文件有权限方面问题,如果不是-a可能无法启动DNS服务器

重启DNS服务
service named restart  //确认区域文件命名没错,一步步确认,不要走回头路,DNS配置很敏感的

修改区域配置文件

vi localhost.zone abc.test1.zone

$TTL 86400
@     IN SOA www.abc.test1. root.abc.test1. (
42; serial (d.adams)
3H; refresh
15M; retry
1W; expiry
1D); minimum


@ IN NS www.abc.test1.
www IN A 192.168.1.151

vi 192.168.1.local

$TTL 86400
@     IN SOA www.abc.test1. root.abc.test1. (
1997022700; serial (d.adams)
28800; refresh
14400; retry
3600000; expiry
86400); minimum


@ IN NS www.abc.test1.
111 IN A www.abc.test1.

重启DNS服务

service named restart

校验DNS情况


配置客户端DNS服务器
  • vi /etc/resolve.conf 
  • 输入nameserver 192.168.1.150
填写完毕后,终端输入nslookup www.chipcore.test1 ,有信息返回代表正确


主要,DNS对语法非常敏感,多备份,一步步测试,注意域名是www.abc.test1. 后面是带一个“.”号的

另外,测试客户机注意清空DNS缓存。



你可能感兴趣的:(redhat,service,SOA,caching,DNS服务器,recursion)