# bind fails to start [solved ... I think]

## morphal

I'm attempting to setup a netreg server for my university ... cause I'm obviously the best person for the job.  :Rolling Eyes:  Nevertheless, I'm doing it.

I think everything's started correctly except for Bind. It's killing me. I don't really even know where to begin so I'll just post the log and see where things go from there.

```
Jul 26 10:08:57 [named] starting BIND 9.2.5 -u named -n 1

Jul 26 10:08:57 [named] using 1 CPU

Jul 26 10:08:57 [named] loading configuration from '/etc/bind/named.conf'

Jul 26 10:08:57 [named] listening on IPv4 interface eth0, <my ip>#53

Jul 26 10:08:57 [kernel] process `named' is using obsolete setsockopt SO_BSDCOMPAT

Jul 26 10:08:57 [named] listening on IPv4 interface eth0:1, <ip alias>#53

Jul 26 10:08:57 [named] listening on IPv4 interface lo, 127.0.0.1#53

Jul 26 10:08:57 [named] /etc/bind/named.conf:19: couldn't find key 'rndckey' for use with command channel 127.0.0.1#953

Jul 26 10:08:57 [named] command channel listening on 127.0.0.1#953

Jul 26 10:08:57 [named] couldn't open pid file '/var/run/named.pid': Permission denied

Jul 26 10:08:57 [named] exiting (due to early fatal error)
```

Any ideas?Last edited by morphal on Wed Jul 27, 2005 10:03 pm; edited 4 times in total

----------

## kashani

Yeah there is a bug in the Bind scripts. I fixed it by doing

mkdir /var/run/named/

chown named: /var/run/named/

Then vi /etc/init.d/named and change any instance of /var/run/named.pid to /var/run/named/named.pid

Then vi /etc/bind/named.conf and change add or change the pid file to the following.

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

Then it should work. You may need to run /etc/init.d/named zap before trying to start Bind again.

kashani

----------

## morphal

Dude, you have no idea how awesome you are. You've answered two of my questions in a row (although I haven't got that mysql problem worked out yet ... that's my home project though, this is work). I do wonder though, named.conf has a few different sections in it. Just where should I add that pid-file line?

----------

## kashani

I've been working on a Gentoo BIND document. It's fairly likely to lead you astray in places, but does have some good info in it.

http://gentoo-wiki.com/HOWTO_Setup_a_DNS_Server_with_BIND

Let me know if it helps you and feel free to add to the discussion or PM me with edits. In any case you'd want to add the pid-file inside the options {} part.

kashani

----------

## morphal

Alright, named starts now but I can only assume my zone file is wrong. Essentially, what I'm trying to do is create a bogus nameserver. All domain names, except for a few that I have exceptions set up for, should resolve back to my server. I'm really tired of dealing with programs that almost work. (Refering to NetReg and the suite of programs it depends on, Named being borked is completely my own inexperience. )

```
options {

        directory "/var/named";

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

};

controls {

        inet 127.0.0.1 allow { localhost; } keys { rndckey; };

};

zone "microsoft.com" { type forward; forwarders { 129.7.1.1; }; forward only; };

<tons of additional exceptions, edited for brevity>

## Wilcard zone

zone "." {

        type master;

        file "named.ca";

};

include "/etc/rndc.key";
```

What needs to change?

----------

## chiasmus1

I am not sure these will work for you:

```
<tons of additional exceptions, edited for brevity>

## Wilcard zone 
```

In the named.conf file you can change these to comments like this:

```
// <tons of additional exceptions, edited for brevity>

// ## Wilcard zone 
```

----------

## morphal

Well, the bit about the additional exceptions isn't there in the real file. I was just noting that I had a whole lot of exceptions like the previous entry that I just edited out so my post wouldn't be two pages long.

I can remove the other comment entirely, it's just a comment and serves no real purpose.

----------

## morphal

named starts but it has issues stopping properly. I've actually killed the process and when trying to restart net.eth0, I get the message that named is still running and can't be shut down. There's not even a pid file left and it's giving me fits.

```
#!/sbin/runscript

# Copyright 1999-2004 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc6,v 1.15 2004/07/14 23:18:19 agriffis Exp $

opts="start stop reload restart"

depend() {

   need net

   use logger

   provide dns

}

checkconfig() {

   if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then

      eerror "No ${CHROOT}/etc/bind/named.conf file exists!"

   fi

   

   # In case someone doesn't have $CPU set from /etc/conf.d/named

   if [ ! ${CPU} ] ; then

      CPU="1"

   fi

   # As with the named.conf test, above, there's no need

   # for chroot and non-chroot cases here

   PIDFILE=$(grep "pid-file" ${CHROOT}/etc/bind/named.conf | \

      egrep -v ".*[#,//].*pid-file" | \

      head -n 1 | \

      sed -ne 's:.*pid-file \"\(.*\)\";:\1:p')

   [ -n "$PIDFILE" ] || PIDFILE=/var/run/named/named.pid

   PIDFILE="${CHROOT}$PIDFILE"

   KEY="${CHROOT}/etc/bind/rndc.key"

}

start() {

   ebegin "Starting ${CHROOT:+chrooted }named"

   checkconfig || return 1

   start-stop-daemon --start --quiet --pidfile ${PIDFILE} \

      --exec /usr/sbin/named \

      -- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t $CHROOT}

   eend $?

}

stop() {

   ebegin "Stopping ${CHROOT:+chrooted }named"

   checkconfig || return 2

   start-stop-daemon --stop --quiet --pidfile $PIDFILE \

      --exec /usr/sbin/named -- stop

   eend $?

}

reload() {

   checkconfig || return 3

   if [ ! -f $PIDFILE ] ; then

      /etc/init.d/named start &>/dev/null

      exit

   fi

   if [ -f $KEY ] ; then

      ebegin "Reloading named.conf and zone files"

      rndc -k $KEY reload &>/dev/null

      eend $?

   else /etc/init.d/named restart &>/dev/null

   fi

}

restart() {

   svc_stop

   svc_start

}
```

Aw hell ... I think zap worked ... waste of a post ...

----------

## Double Click

 *kashani wrote:*   

> Yeah there is a bug in the Bind scripts. I fixed it by doing
> 
> mkdir /var/run/named/
> 
> chown named: /var/run/named/
> ...

 

Awesome! Had to do a emergency install of BIND and never played around with it. Got so badly stuck on this bug ...

----------

