LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting up DNS in RHEL5 (newbie) (https://www.linuxquestions.org/questions/linux-newbie-8/setting-up-dns-in-rhel5-newbie-892163/)

iluvAS 07-17-2011 08:12 AM

Setting up DNS in RHEL5 (newbie)
 
Hi there, I've been googling for solutions but I couldn't find much that explains how named.conf and zone files work. Anyways for my school project using RHEL5 I am suppose to set up the following:
  • a DNS master server for the domain p0920948.com
  • I will be using bind-chroot
  • I have two machines one server (172.16.112.39/24) and another client (172.16.112.40/24)
  • Client has to be able to ping server by p0920948S1.p0920948.com
  • This part im not sure what it means by "dig" but its in the instructions: dig p0920948S1.p0920948.com
  • Client able to ping server by aliased www.p0920948.com
  • client able to ping itself by p0920948C1.p0920948.com

So what I've done so far is
  1. install bind and chroot
  2. write the command chkconfig named on to start it on boot
  3. Copied some files from /usr/share/doc/bind-*/sample into chroot
  4. Modified resolve.config adding in "nameserver 127.0.0.1" for localhost
  5. Add in "listen-on port 53 {127.0.0.1; 172.16.112.39; 172.16.112.40};" under the options bracket in named.conf
  6. declared an acl "safe-subnet" {172.16.112.0/24}; and added it into the match-clients and match-destinations for internal
  7. And within internal i added in a zone file refrence
  8. I modified named.root.hints to add in a zone reference as well
  9. Created the zone file

NAMED.CONF FILE
Code:

//
// 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
{
        listen-on port 53 { 127.0.0.1; 172.16.112.39; 172.16.112.40; };
        // 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; };
        match-destinations        { localhost; };
        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:
        */
        include "/etc/named.rfc1912.zones";
};

acl "safe-subnet" { 172.16.112.0/24; };

view "internal"
{
/* This view will contain zones you want to serve only to "internal" clients
  that connect via your directly attached LAN interfaces - "localnets" .
 */
        match-clients                { localnets; localhost; safe-subnet; };
        match-destinations        { localnets; localhost; safe-subnet; };
        recursion yes;
        // all views must contain the root hints zone:
        include "/etc/named.root.hints";

        // include "named.rfc1912.zones";
        // you should not serve your rfc1912 names to non-localhost clients.
 
        // These are your "authoritative" internal zones, and would probably
        // also be included in the "localhost_resolver" view above :

        zone "p0920948.com" {
                type master;
                notify no;
                allow-query { any; };
                file "var/named/zones/internal/p0920948.zone";
        };
               
        zone "my.internal.zone" {
                type master;
                file "my.internal.zone.db";
        };
        zone "my.slave.internal.zone" {
                type slave;
                file "slaves/my.slave.internal.zone.db";
                masters { /* put master nameserver IPs here */ 127.0.0.1; } ;
                // put slave zones in the slaves/ directory so named can update them
        };       
        zone "my.ddns.internal.zone" {
                type master;
                allow-update { key ddns_key; };
                file "slaves/my.ddns.internal.zone.db";
                // put dynamically updateable zones in the slaves/ directory so named can update them
        };                       
};
key ddns_key
{
        algorithm hmac-md5;
        secret "use /usr/sbin/dns-keygen to generate TSIG keys";
};
view    "external"
{
/* This view will contain zones you want to serve only to "external" clients
 * that have addresses that are not on your directly attached LAN interface subnets:
 */
        match-clients                { any; };
        match-destinations        { any; };

        recursion no;
        // you'd probably want to deny recursion to external clients, so you don't
        // end up providing free DNS service to all takers

        allow-query-cache { none; };
        // Disable lookups for any cached data and root hints

        // all views must contain the root hints zone:
        include "/etc/named.root.hints";

        // These are your "authoritative" external zones, and would probably
        // contain entries for just your web and mail servers:

        zone "my.external.zone" {
                type master;
                file "my.external.zone.db";
        };
};

NAMED ROOT HINTS
Code:

//
//  The 'named.root' root cache hints zone for the bind DNS 'named' nameserver.
//
//  named's cache must be primed with the addresses of the root zone '.' nameservers.
//  The root zone file can be obtained by querying the root 'A' nameserver:
//    $ dig . ns @198.41.0.4 > named.root
//  Or by download via FTP / HTTP:
//    $ wget ftp://ftp.rs.internic.net/domain/named.root
// 
//  Every view that is to provide recursive service must include this zone.
//
zone "." IN {
        type hint;
        file "named.root";
};

zone "p09209498.com" IN {
  type master;
  file "/var/named/zones/internal/p0920948.zone";
  allow-update { none; };
};


zone file "p0920948.zone"
Code:

;
; Zone file for p0920948.com
;
; The full zone file
;
$TTL 3D
@      IN      SOA    www.p0920948.com. hostmaster.p0920948.com. (
                      200211152      ; serial#
                      3600            ; refresh, seconds
                      3600            ; retry, seconds
                      3600            ; expire, seconds
                      3600 )          ; minimum, seconds

                          NS      www            ; Inet Address of nameserver
p0920948S1.p0920948.com.  A      10 p0920948S1  ; Server
p0920948C1.p0920948.com.  A      10 p0920948C1        ; Client

p0920948S1      A      172.16.112.39
p0290948C1        A        172.16.112.40
www            CNAME  p0920948S1

INTERNAL_ZONES.CONF
Code:

zone "p09209498.com" IN {
  type master;
  file "/var/named/zones/internal/p0920948.zone";
  allow-update { none; };
};

After all that when i execute the /etc/init.d/named restart command, i got bombarded with errors and I tried debugging line by line and gave up when i realize its due to my lack of the concept on how zone files work and me copying chunks of code i find online thats causing the errors. So it would be great if anyone can help explain the concept or point out some of the mistakes i make.

Thanks for reading my epicly long post, any help will be greatly appreciated.

iluvAS 07-17-2011 09:53 AM

I found out i had some typo errors such as typing in p09209498 instead of p0920948, i fixed that and i got the error

/etc/named.conf:86: zone 'p0920948.com' :already exists previous definition /etc/named.root.hints:17

So i decided to remove the zone declaration of p0920948 inside named.conf, i finally get no errors but when it displays Starting named: it shows [FAILED]

any ideas what could be wrong?

bathory 07-17-2011 10:48 AM

You can check logs in /var/log/messages and/or /var/log/syslog
You can also run:
Code:

named-checkconf -z -t /var/named/chroot
to check the configuration, assuming you run bind chrooted under /var/named/chroot.

chrism01 07-17-2011 05:57 PM

As you're on RHEL 5, I recommend this manual http://www.linuxtopia.org/online_boo...ion/index.html


All times are GMT -5. The time now is 01:31 PM.