# BIND 9 won't start using /etc/init.d/named start

## simeli

I have a strange problem trying to get bind working. I want to set up a chaching dns for my home network and name resolution for my local cia domain. I have done a fresh install of 2005.1-r1 and emerged bind with

```
emerge -av net-dns/bind-9.2.5-r6  -berkdb -bind-mysql -dlz -doc -idn -ipv6 -ldap -mysql -odbc -postgres (-selinux) +ssl -threads*
```

this is my /etc/bind/named.conf file:

```
options {

        directory "/var/named"; // sets root dir, use full path to escape

//        statistics-file "/var/named/named.stats"; // stats are your friend

//        dump-file "/var/named/named.dump";

//        zone-statistics yes;

//        allow-recursion { 127.0.0.1; 10.0.0.0/8; }; // allow recursive lookups

//        allow-transfer { 10.11.12.1; 10.11.12.2; }; // allow transfers to these IP's

//        notify yes; // notify the above IP's when a zone is updated

//        also-notify { 10.110.0.11; 10.120.0.11; }; // notify these other servers when a zone is updated

        pid-file "/var/run/named.pid"; // location of pid file

//        transfer-format many-answers; // Generates more efficient zone transfers

        forwarders { 129.132.98.12; 129.132.250.220; 212.40.13.110; };

};

// Include logging config file

//include "/var/named/conf/logging.conf";

// Include to ACLs

//include "/var/named/conf/acls.conf";

// Include customer zones

//include "/var/named/conf/customer1.conf";

//include "/var/named/conf/customer2.conf";

zone "cia" {

        type master;

        file "/var/named/cia.hosts";

        };
```

When I try to run /etc/init.d/named start I get the following output:

```
 * Caching service dependencies ...                                       [ ok ]

 * Starting chrooted named ...

usage: named [-c conffile] [-d debuglevel] [-f|-g] [-n number_of_cpus]

             [-p port] [-s] [-t chrootdir] [-u username]

named: extra command line arguments                                       [ !! ]
```

nothing gets logged in /var/log/messages. When I start with /usr/sbin/named & I get the following in /var/log/messages:

```
horus ~ # tail /var/log/messages 

Dec 29 14:30:01 horus cron[29074]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

Dec 29 14:32:38 horus named[29203]: starting BIND 9.2.5

Dec 29 14:32:38 horus named[29203]: using 1 CPU

Dec 29 14:32:38 horus named[29203]: loading configuration from '/etc/bind/named.conf'

Dec 29 14:32:38 horus named[29203]: listening on IPv4 interface lo, 127.0.0.1#53

Dec 29 14:32:38 horus process `named' is using obsolete setsockopt SO_BSDCOMPAT

Dec 29 14:32:38 horus named[29203]: listening on IPv4 interface eth0, 10.0.1.10#53

Dec 29 14:32:38 horus named[29203]: command channel listening on 127.0.0.1#953

Dec 29 14:32:38 horus named[29203]: zone cia/IN: loaded serial 1135794189

Dec 29 14:32:38 horus named[29203]: running

horus ~ # ps aux | grep named

root     29203  0.0  0.2   4500  2072 ?        Ss   14:32   0:00 /usr/sbin/named

root     29206  0.0  0.0   1508   468 pts/1    S+   14:33   0:00 grep named
```

Even if I do an 

```
emerge --config '=net-dns/bind-9.2.5-r6'
```

 the same thing happens. Am I just overlooking something stupid? It seems that no one else has this problem. Any help would be greatly appreciated. Also, if I would like to change the chroot jail to /var/chroot/dns, can I just edit /etc/conf.d/named and do another emerge --config '=net-dns/bind-9.2.5-r6'?

----------

## steveb

Could you post the content of your /etc/conf.d/named file?

Gruess us Züri

Steve

----------

## simeli

latuerlich   :Laughing: 

here it is:

```
# Set various named options here.

#

OPTIONS=""

# Set this to the number of processors you have.

#

CPU="1"

# If you wish to run bind in a chroot, run:

# emerge --config =<bind-version>

# and un-comment the following line.

# You can specify a different chroot directory but MAKE SURE it's empty.

CHROOT="/chroot/dns"

```

au us zueri.

----------

## steveb

hmmm.... /var/named??? Should that not be /var/bind? Do you have the /var/named directory?

Züri? Aha! Von wo? Ich aus 8038. Und Du?

Gruss

Steve

----------

## kashani

As the guy who wrote the How-to it looks like you're using, I think I see your problem. 

1. My how-to doesn't chroot. I need to fix that, but you're missing a few things because of that.

2. There is a section on of the how-to where you create ln -sf /etc/bind /etc/named  and other things to keep admins coming from other distros from being a confused. You appear to missing that as well.

kashani

----------

## simeli

I have tried with and w/o chroot. same thing. What I don't quite understand is that it ran when starting it directly with /usr/sbin/named.

I have double checked on the symlinks but those were ok. what are the custormer1 and 2 for anyway? Would that be the same as my cia zone? so right now i am (trying) running without chroot and bare install as described. no luck so far.

@steveb zurich 8037 nordstrasse hinter limmatplatz. mal zeit fuer ein bier?

----------

## steveb

I think it is the pid file /var/run/named.pid giving you that error. Could you check if the user named group named can create a file in /var/run/ with the name named.pid?

@simeli: Bin nicht so ein Bier Trinker. Aber wir können uns mal dennoch treffen  :Wink: 

cheers

SteveB

----------

## simeli

right, named was not allowed to write to /var/run. i followed the howto on http://gentoo-wiki.com/HOWTO_Setup_a_DNS_Server_with_BIND#named.conf and created a /var/run/named directory to store the pid file and changed it accordingly in /etc/bin/named.conf and /etc/init.d/named. no success however. I also tried to create a new configuration using webmin - gives me the same error. i am kinda lost really...

@steveb kann natuerlich auch was anderes sein   :Wink:  schick dir mal ne pm mit meinen daten

----------

## steveb

 *simeli wrote:*   

> right, named was not allowed to write to /var/run. i followed the howto on http://gentoo-wiki.com/HOWTO_Setup_a_DNS_Server_with_BIND#named.conf and created a /var/run/named directory to store the pid file and changed it accordingly in /etc/bin/named.conf and /etc/init.d/named. no success however. I also tried to create a new configuration using webmin - gives me the same error. i am kinda lost really...

 

could you do this:

```
chown named:named /var/run/named

chmod 744 /var/run/named
```

i would as well move cia.hosts away from /var/named into /etc/bind/pri and I would name it cia.zone. But this is more a cosmetical stuff:

```
mv -i -v /var/named/cia.hosts /etc/bind/pri/cia.zone

sed -i "s:^\([ \t]*file[ \t]*\"\)/var/named/cia.hosts".*:\1pri/cia.zone\";:gI" /etc/bind/named.conf
```

cheers

SteveB

btw: Ich könnte Dich auch auf dem Natel anrufen und wir können das ganz einfach über das Telefon lösen. Wenn Du willst...

----------

## Meradan

I had the same problem and I've also followed the mentioned HOWTO, and after some debugging I've found that the fault is coming from the declaration of the pid-file in the config. As the init.d script parses the file for the pid file to use, it doesn't remove the comment.  So change the line:

```
pid-file "/var/run/named/named.pid"; // location of pid file
```

to

```
pid-file "/var/run/named/named.pid";
```

and everything works fine again. At least, that was the case for me  :Smile: 

----------

## steveb

 *Meradan wrote:*   

> I had the same problem and I've also followed the mentioned HOWTO, and after some debugging I've found that the fault is coming from the declaration of the pid-file in the config. As the init.d script parses the file for the pid file to use, it doesn't remove the comment.  So change the line:
> 
> ```
> pid-file "/var/run/named/named.pid"; // location of pid file
> ```
> ...

 AAAAAAAAAGGRRRH!! Where have you been jesterday?!?!?

I just had a quick phone call with simeli and we found out the same solution to the problem. The funny part is, that I have a newer version of BIND9 on my system, where this issue is solved. After looking into the init.d script I see why:

```
        # as suggested in bug #107724

        [ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\

                egrep -v \

                        "^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" \

                        ${CHROOT}/etc/bind/named.conf \

                                | egrep -o -m1 "pid\-file +\".+\" *;" \

                                | cut -d\" -f2

        )
```

--> Bad pid-file parsing prevents bind init script from starting

cheers

SteveB

----------

## simeli

Thanks a bunch you guys!   :Smile: 

----------

## Meradan

 *steveb wrote:*   

> AAAAAAAAAGGRRRH!! Where have you been jesterday?!?!?
> 
> 

 

Well, yesterday I was having some big troubles with my server which led me to the inevitable reboot, and this in turn made me aware of this problem a couple of hours ago  :Smile: 

----------

## kenetic9mm

I think I may have a related problem.

BACKGROUND: When my server crashed a while back, I noticed that my apache2 virtual name domain was no longer resolved from the internet.  Further digging lead me to see that the bind wasn't running.

PROBLEM:  When I try to start bind I get the following error:

 *Quote:*   

> start-stop-daemon: --start needs --exec or --startas
> 
>   start-stop-daemon --help' for more information.

 

But /etc/init.d/named ran fine before the crash and contains --start:

 *Quote:*   

> 
> 
> #!/sbin/runscript
> 
> # Copyright 1999-2004 Gentoo Foundation
> ...

 

QUESTION: Do I need to update the script?

 *Quote:*   

>      # as suggested in bug #107724
> 
>         PIDFILE=$(\
> 
>                 egrep -v \
> ...

 

I do not see the named process running and the status is stopped.

END GOAL: To get my virtual name domain working again.   :Crying or Very sad: 

I'd appreciate any insight.  I am assuming that starting up bind will get my virtual name domain working again.  Thanks in advance!    :Very Happy: 

----------

