problem with starting named/Bind services in CentOS release 5.X
On starting Bind sometimes you get the following error :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# /etc/init.d/named start
Locating /var/named/chroot//etc/named.conf failed: [FAILED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It occurs cause in CENTOS 5.x OS, some of the Bind/named files are not located on the desired location.
Resolution :
~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# locate named.conf
/etc/dbus-1/system.d/named.conf
/usr/share/doc/bind-9.3.6/sample/etc/named.conf
/usr/share/logwatch/default.conf/services/named.conf
/usr/share/man/man5/named.conf.5.gz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You will get a list of paths, similar to the above list. Copy the "named.conf" at /usr/share/doc/bind-9.x.x path to the desired location.
at the my time /chroot/etc directories was not available on sever So, I created it .
[root@sever]# mkdir -p /var/named/chroot/etc
Then, copied the named.conf .
[root@sever]#cp /usr/share/doc/bind-9.3.6/sample/etc/named.conf /var/named/chroot/etc
Note : In case the Bind is not chrooted, copy the file in /etc
Now, try to start the Named/Bind Service :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# /etc/init.d/named start
Error in named configuration:
/etc/named.conf:57: open: /etc/named.root.hints: file not found [FAILED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Locate the "named.root.hints" file on the system:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# locate named.root.hints
/usr/share/doc/bind-9.3.6/sample/etc/named.root.hints
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And Copied it in desire Location:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# cp /usr/share/doc/bind-9.3.6/sample/etc/named.root.hints /var/named/chroot/etc
if Bind is not chrooted:
[root@sever]# cp /usr/share/doc/bind-9.3.6/sample/etc/named.root.hints /etc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now try to start Named/Bind Service :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# /etc/init.d/named start
Starting named:
Error in named configuration:
/etc/named.conf:63: open: /etc/named.rfc1912.zones: file not found [FAILED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
locate the rfc1912.zones :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# locate named.rfc1912
/usr/share/doc/bind-9.3.6/sample/etc/named.rfc1912.zones
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And copied it in :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]#
if Bind is not chrooted:
[root@sever]# cp /usr/share/doc/bind-9.3.6/sample/etc/named.rfc1912.zones /etc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the Named/Bind service :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@sever]# /etc/init.d/named start
Starting named:
Error in named configuration:
zone localdomain/IN: loading master file localdomain.zone: file not found
localhost_resolver/localdomain/IN: file not found
zone localhost/IN: loading master file localhost.zone: file not found
localhost_resolver/localhost/IN: file not found
zone 0.0.127.in-addr.arpa/IN: loading master file named.local: file not found
localhost_resolver/0.0.127.in-addr.arpa/IN: file not found
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: loading master file named.ip6.local: file not found
localhost_resolver/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: file not found
zone 255.in-addr.arpa/IN: loading master file named.broadcast: file not found
localhost_resolver/255.in-addr.arpa/IN: file not found
zone 0.in-addr.arpa/IN: loading master file named.zero: file not found
localhost_resolver/0.in-addr.arpa/IN: file not found
zone my.internal.zone/IN: loading master file my.internal.zone.db: file not found
internal/my.internal.zone/IN: file not found
zone my.ddns.internal.zone/IN: loading master file slaves/my.ddns.internal.zone.db: file not found
internal/my.ddns.internal.zone/IN: file not found
zone my.external.zone/IN: loading master file my.external.zone.db: file not found
external/my.external.zone/IN: file not found
[FAILED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, if you will get the above error, we need to remove some part of data from "named.conf" file. Remove this whole section in the copied "named.conf" file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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";
};
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; };
match-destinations { localnets; };
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 "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 { !localnets; !localhost; };
match-destinations { !localnets; !localhost; };
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
// 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";
};
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now Start the Named/Bind Service :
[root@sever]## /etc/init.d/named start
Starting named: [ OK ]