Linux操作系统(CentOS)之DNS服务器配置与应用

简介: 如何在内网的环境下实习DNS服务器呢?经过1个多星期的时间,终于探索出了DNS配置的方式方法。先分析网络架构和域名安排,再遵照指定的步骤,定能配好! 我的外网IP是10.10.23.144,属于校园网。

如何在内网的环境下实习DNS服务器呢?经过1个多星期的时间,终于探索出了DNS配置的方式方法。先分析网络架构和域名安排,再遵照指定的步骤,定能配好!

我的外网IP是10.10.23.144,属于校园网。内网IP是192.168.0.1,兼做网关,是centos5的双网卡系统。web服务器是192.168.0.2,DNS服务器是192.168.0.1,当然别的服务还可以再在别的IP机器上配置,就如法炮制即可。

需要安装的rpm包有:bind-util-9.3.4、bind-9.3.4、bind-libs-9.3.4、bind-chroot-9.3.4,然后为了快速配置,安装caching-nameserver包,这样就可以省去很多自建文件的麻烦事。安装完毕后,采用了chroot监牢机制,非常安全。这时必须注意:配置文件的实际目录是/var/named/chroot/,虚拟目录如果是/etc,则真实目录是/var/named/chroot/etc。但只有两个目录是常用的,一个是/etc,一个是/var,/etc下放named.conf,剩下的文件放在/var中。

1、named.conf中的内容:
//
// Sample named.conf BIND DNS server 'named' configuration file
// for the Red Hat BIND distribution.
//
// See the BIND Administrator's Reference Manual (ARM) for details, in:
//   file:///usr/share/doc/bind-*/arm/Bv9ARM.html
// Also see the BIND Configuration GUI : /usr/bin/system-config-bind and
// its manual.
//
options
{
        // Those options should be used carefully because they disable port
        // randomization
    query-source    port 53;   
    //query-source-v6 port 53;
   
    // Put files that named is allowed to write in the data/ directory:
    directory "/var/named"; // the default
    dump-file         "data/cache_dump.db";
        statistics-file     "data/named_stats.txt";
        memstatistics-file     "data/named_mem_stats.txt";

};
logging
{
/*      If you want to enable debugging, eg. using the 'rndc trace' command,
 *      named will try to write the 'named.run' file in the $directory (/var/named).
 *      By default, SELinux policy does not allow named to modify the /var/named directory,
 *      so put the default debug log file in data/ :
 */
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };   
};
//
// All BIND 9 zones are in a "view", which allow different zones to be served
// to different types of client addresses, and for options to be set for groups
// of zones.
//
// By default, if named.conf contains no "view" clauses, all zones are in the
// "default" view, which matches all clients.
//
// If named.conf contains any "view" clause, then all zones MUST be in a view;
// so it is recommended to start off using views to avoid having to restructure
// your configuration files in the future.
//
view "localhost_resolver"
{
/* This view sets up named to be a localhost resolver ( caching only nameserver ).
 * If all you want is a caching-only nameserver, then you need only define this view:
 */
    match-clients         { localhost;localnets; };
    match-destinations    { localhost;localnets; };
    recursion yes;
    # all views must contain the root hints zone:
    include "/etc/named.root.hints";

        /* these are zones that contain definitions for all the localhost
         * names and addresses, as recommended in RFC1912 - these names should
     * ONLY be served to localhost clients:
     */
     zone "liukai.com"    {
         type master;
         file "liukai.com.db";
     };
     zone "0.168.192.in-addr.arpa"    IN{
         type master;
         file "liukai.com.db.arpa";
     };
    include "/etc/named.rfc1912.zones";
};

2、liukai.com.db中的内容:
@ in soa localhost. root 1 3H 15M 1W 1D
  ns localhost.
dns    IN    A    192.168.0.1
www    IN    A    192.168.0.2
ok    IN    CNAME    www
ko    IN    CNAME    www

3、liukai.com.db.arpa中的内容:
@ in soa localhost. root 1 3H 15M 1W 1D
  ns localhost.
2    IN    PTR    www.liukai.com
1    IN    PTR    dns.liukai.com

4、named.root.hints中的内容:(也放在/var/named/chroot/var/named);       This file holds the information on root name servers needed to
;       initialize cache of Internet domain name servers
;       (e.g. reference this file in the "cache  .  "
;       configuration file of BIND domain name servers).
;
;       This file is made available by InterNIC
;       under anonymous FTP as
;           file                /domain/named.root
;           on server           FTP.INTERNIC.NET
;       -OR-                    RS.INTERNIC.NET
;
;       last update:    Dec 12, 2008
;       related version of root zone:   2008121200
;
; formerly NS.INTERNIC.NET
;
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
A.ROOT-SERVERS.NET.      3600000      AAAA  2001:503:BA3E::2:30
;
; FORMERLY NS1.ISI.EDU
;
.                        3600000      NS    B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET.      3600000      A     192.228.79.201
;
; FORMERLY C.PSI.NET
;
.                        3600000      NS    C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12
;
; FORMERLY TERP.UMD.EDU
;
.                        3600000      NS    D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90
;
; FORMERLY NS.NASA.GOV
;
.                        3600000      NS    E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10
;
; FORMERLY NS.ISC.ORG
;
.                        3600000      NS    F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241
F.ROOT-SERVERS.NET.      3600000      AAAA  2001:500:2F::F
;
; FORMERLY NS.NIC.DDN.MIL
;
.                        3600000      NS    G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4
;
; FORMERLY AOS.ARL.ARMY.MIL
;
.                        3600000      NS    H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53
H.ROOT-SERVERS.NET.      3600000      AAAA  2001:500:1::803F:235
;
; FORMERLY NIC.NORDU.NET
;
.                        3600000      NS    I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17
;
; OPERATED BY VERISIGN, INC.
;
.                        3600000      NS    J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30
J.ROOT-SERVERS.NET.      3600000      AAAA  2001:503:C27::2:30
;
; OPERATED BY RIPE NCC
;
.                        3600000      NS    K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129
K.ROOT-SERVERS.NET.      3600000      AAAA  2001:7FD::1
;
; OPERATED BY ICANN
;
.                        3600000      NS    L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET.      3600000      A     199.7.83.42
L.ROOT-SERVERS.NET.      3600000      AAAA  2001:500:3::42
;
; OPERATED BY WIDE
;
.                        3600000      NS    M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33
M.ROOT-SERVERS.NET.      3600000      AAAA  2001:DC3::35
; End of File


本主机DNS设置主DNS为192.168.0.1,就可以了,但对外网域名解析较慢,可以增加次DNS为210.47.176.1(具体地区的是有区别的,我这是辽宁的)。客户机DNS都设为192.168.0.1就可以了,当然你也可以设置客户机的次DNS为210.47.176.1,这样更稳妥些,不过解析速度不会快的。注意:要想访问内网网址,必须把192.168.0.1设为首选DNS服务器哦。。。

相关文章
|
弹性计算 安全 Linux
阿里云服务器ECS安装宝塔Linux面板、安装网站(新手图文教程)
本教程详解如何在阿里云服务器上安装宝塔Linux面板,涵盖ECS服务器手动安装步骤,包括系统准备、远程连接、安装命令执行、端口开放及LNMP环境部署,手把手引导用户快速搭建网站环境。
|
安全 Linux Shell
使用SCP命令在CentOS 7上向目标服务器传输文件
以上步骤是在CentOS 7系统上使用SCP命令进行文件传输的基础,操作简洁,易于理解。务必在执行命令前确认好各项参数,尤其是目录路径和文件名,以避免不必要的传输错误。
1252 17
|
NoSQL 安全 Linux
设置Redis在CentOS7上的自启动配置
这些步骤总结了在CentOS 7系统上设置Redis服务自启动的过程。这些命令提供了一个直接且明了的方式,确保Redis作为关键组件在系统启动时能自动运行,保障了依赖于Redis服务的应用的稳定性和可用性。
1016 9
|
Ubuntu 安全 小程序
服务器版本的CentOS和Ubuntu哪个更适合你?
但是以上的比较并不说明Ubuntu是不稳定的或者是不安全的,只是以上比较过程中,在稳定性方面Ubuntu稍微逊色了一点。由于Ubuntu在个人桌面电脑的使用率远远高于CentOS,用Ubuntu搭建服务器,如果遇到什么问题,寻找解决方案相对比较容易,这让Ubuntu在选择方面更优于CentOS。如果你是一个初学者,那么毫无疑问Ubuntu是更适合的选择。如果你正在经营自己的公司,在这两者之间,CentOS会更好一些。
|
安全 关系型数据库 网络安全
安全加固:启动PostgreSQL 14服务器SSL加密的方法指南在CentOS 7环境中
通过上述步骤,你可以为PostgreSQL数据库服务器设置SSL加密,从而增加数据在传输中的安全性。确保维持证书的有效性,并且定期更新和管理密钥,以防止未授权访问。
661 0
|
监控 Linux 网络安全
FinalShell SSH工具下载,服务器管理,远程桌面加速软件,支持Windows,macOS,Linux
FinalShell是一款国人开发的多平台SSH客户端工具,支持Windows、Mac OS X和Linux系统。它提供一体化服务器管理功能,支持shell和sftp同屏显示,命令自动提示,操作便捷。软件还具备加速功能,提升访问服务器速度,适合普通用户和专业人士使用。
4509 0
|
存储 安全 Linux
Linux服务器上安装配置GitLab的步骤。
按照以上步骤,一个基础的GitLab服务应该运行并可以使用。记得定期检查GitLab官方文档,因为GitLab的安装和配置步骤可能随着新版本而变化。
1174 0
|
Linux
5款优秀的Linux便携式应用
译文出自:5款优秀的Linux便携式应用
884 0
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
1175 1
二、Linux文本处理与文件操作核心命令

相关产品

  • 云解析DNS