Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3013448
  • 博文数量: 454
  • 博客积分: 4860
  • 博客等级: 上校
  • 技术积分: 6375
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 10:08
个人简介

10年工作经验,专研网站运维。

文章分类

全部博文(454)

文章存档

2017年(11)

2016年(13)

2015年(47)

2014年(36)

2013年(147)

2012年(64)

2011年(136)

分类: LINUX

2011-03-26 11:33:56

vim /var/named/chroot/var/named/hrsx.com.zone


rhel 5 dns 配置
首先,应该检查自己是否已经安装了bind。
[root@killgoogle ~]# rpm -qa bind*
bind-chroot-9.3.3-10.el5
bind-9.3.3-10.el5
bind-libbind-devel-9.3.3-10.el5
bind-utils-9.3.3-10.el5
bind-sdb-9.3.3-10.el5
bind-devel-9.3.3-10.el5
bind-libs-9.3.3-10.el5

还有一个比较重要的包是caching-nameserver
[root@killgoogle ~]# rpm -qa caching-nameserver
caching-nameserver-9.3.3-10.el5
如果没有安装这些包的话可以用:以下方法安装
[root@killgoogle ~]# yum install bind*
[root@killgoogle ~]# yum install caching-nameserver
安装过后BIND服务就已经完成三分之一了,剩下的三分之二就是配置BIND服务。我是想配置一个DNS可以解析
我的域名:假设我的IP是:192.168.1.102
[root@killgoogle ~]# cd /var/named/chroot/etc/
[root@killgoogle etc]# ls
localtime                              named.rfc1912.zones
named.caching-nameserver.conf          named.rfc1912.zones.rpmsave
rndc.key        
[root@killgoogle etc]# cp -rap named.caching-nameserver.conf named.conf
现在就可以用named.conf文件进行配置了。(对原文件进行了改变的地方--------------)
[root@killgoogle etc]# vi named.conf
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";
    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; };-----------------------------------------------------
    match-destinations { any; };--------------------------------------------------------
    recursion yes;
zone "hrsx.com"{-------------------------------------------------------------------------
        type master;-------------------------------------------------------------------
        file "hrsx.com.zone";-----------------------------------------------------------
};-----------------------------------------------------------------------------
    include "/etc/named.rfc1912.zones";
};
[root@killgoogle var]# cd /var/named/chroot/var/named/
[root@killgoogle var]# cp -rap localdomain.zone hrsx.com.zone
在这之中比较重要的还是要加参数P,要不然很有可能启动不了named服务。好了,现在就可以编辑这两个文件了。
vim zhaopin.com.zone
$TTL    86400
@               IN SOA  localhost. root.localhost. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           hrsx.com.
localhost       IN A            127.0.0.1
liuyi           IN A            192.168.1.66
yiyi            IN A            192.168.1.1
www             IN A            192.168.1.1
xxx             IN A            192.168.1.55
yyy             IN A            192.168.1.155
zhaopin.com.     IN MX   10      mailser.hrsx.com.
修改/etc/resolv.conf文件了.只有修改了这个文件才可以用自己的的机器进行域名解析
[root@killgoogle var]# vi /etc/resolv.conf
只要加上一句:nameserver 192.168.41.12就行了。
这样配置就完成了。不过现在开始配置rhel5的selinux。因为不配置这个的话就不会让别人访问你的DNS服务器。
[root@killgoogle var]# setup
弹出一个对话框。我们要进行的是防火墙配置,所以选择第六个选项:防火墙配置。选择“定制”再在弹出的
对话框的允许进入的最后一栏即:其它端口里输入:53:tcp 53:udp
好了。这样就完成了所有过程。或者直接关闭selinux和iptables测试:
[root@killgoogle ~]# nslookup
> liuyi.hrsx.com
Server:         192.168.41.12
Address:        192.168.41.12#53
Name:   liuyi.
Address: 192.168.41.12
总结:DNS就两个主要配置文件
一、/var/named/chroot/etc/named.conf:这个是主配置文件。
二、/var/named/chroot/var/named/hrsx.com.zone这个是区域配置文件。
两个配置文件位置别错了就可以了。内容别错了就可以了。
cp localdomain.zone   hrsx.com.zone即可
hrsx.com.zone:***********************************************************************
$TTL    86400
@               IN SOA  localhost. root.localhost. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           hrsx.com.
localhost       IN A            127.0.0.1
liuyi           IN A            192.168.1.66
yiyi            IN A            192.168.1.1
www             IN A            192.168.1.1
xxx             IN A            192.168.1.55
yyy             IN A            192.168.1.155
cp -p named.caching-nameserver.conf named.conf即可!!
named.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; };
        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 { localhost; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { any; };
        match-destinations { any; };
        recursion yes;
zone "hrsx.com"{
        type master;
        file "hrsx.com.zone";
};
        include "/etc/named.rfc1912.zones";
};
二、设置dns转发:
vi /var/named/chroot/etc/named.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).
//
//
// 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";
        // randomization
        // query-source    port 53;
        // query-source-v6 port 53;
        allow-query     { any; };
        allow-query-cache { any; }; ------------------------------------------------
        forwarders {-----------------------------------------------------------------
                        202.96.69.38;
                        202.96.64.68;
};
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { any; };
        match-destinations { any; };
        recursion yes;
zone "hrsx.com"{
        type master;
        file "hrsx.com.zone";
        forwarders { 202.96.69.38; };---------------------------------------
};
        include "/etc/named.rfc1912.zones";
};
/etc/init.d/named restart
注意:把所有的localhost都改成any最好!!


查看mx记录:
host -t mx some.domain.name
dig mx other.domain.name
 
阅读(2041) | 评论(0) | 转发(0) |
0

上一篇:博文前言

下一篇:常用系统管理

给主人留下些什么吧!~~