# BIND 9, chroot, named_flags = fail



## ts_fbsd (Mar 13, 2012)

I'm running FreeBSD 9 and I recently instlaled bind98 from ports.  Install went fine.  However, my previous configuration (bind96) did not work with this version of BIND.  Well, the configuration was okay, but the rc.conf setup didn't work.  It looks like bind98 ignored my "named_flags" settings:


```
named_flags="-u bind -c /etc/named.conf"
```

That path is relative to my chroot for BIND.  bind98 seems to only want to load named.conf from the following location:
/etc/namedb/named.conf

All the other rc.conf settings are okay, but unless *I* have named.conf in /etc/namedb/, startup fails with the message:


```
/etc/rc.d/named: ERROR: get_pidfile_from_conf: /etc/namedb/named.conf does not exist (named)
```

If I start named manually, it is able to pick up my configuration file.  This works fine:

[cmd=]named -u bind -t /var/chroot/named -c /etc/named.conf[/cmd]

So, my question is: did something change in the way bind98 works in regards to the location of the configuration?  Does it have to be in that specific location?  Or, is there a bug in the /etc/rc.d/named startup script?

Thanks for whatever information you can provide.


----------



## SirDice (Mar 13, 2012)

The standard BIND also uses /etc/named/named.conf. This has been the case for as long as I can remember.

From /etc/defaults/rc.conf:

```
named_conf="/etc/namedb/named.conf"     # Path to the configuration file
```


----------



## ts_fbsd (Mar 13, 2012)

Yes, but I used to be able to override that with the "named_flags" variable in /etc/rc.conf.  Alas, looking in /etc/default/rc.conf, I see that the "-c" and "-u" options seem to have been deprecated from the "named_flags" variable:


```
#named_flags=""                 # Use this for flags OTHER than -u and -c
```

So, now if I try to use the "named_conf" variable to specify the named.conf file, it still doesn't work:


```
named_conf="/etc/named.conf"

...

# /etc/rc.d/named start
/etc/rc.d/named: ERROR: get_pidfile_from_conf: /etc/named.conf does not exist (named)
```

And if I try to specify the full path in the "named_conf" variable, I get another error about includng the path to my chroot:

```
named_conf="/var/chroot/named/etc/named.conf"

...

# /etc/rc.d/named start
/etc/rc.d/named: WARNING: named chroot: /var/chroot/named/etc is a directory!
rndc-confgen: create keyfile: file not found
Starting named.
named: config filename (-c /var/chroot/named/etc/named.conf) contains chroot path (-t /var/chroot/named)
/etc/rc.d/named: WARNING: failed to start named
```

If I leave the config file as /etc/namedb/named.conf in /etc/defaults/rc.conf then everything works fine and dandy.  However, I've had my config file in /etc/named.conf in the named chroot for the past 12 years without a problem, and I just hate having to change it because a startup script isn't properly reading the value of a variable.  

Still, thanks for pointing out that information.  At least now I know that -u and -c are no longer used in "named_flags".


----------



## wmoreno3 (Jan 25, 2013)

ts_fbsd, your thread help me, 
Problem:

```
root@server:/etc # /etc/rc.d/named start
/etc/rc.d/named: ERROR: get_pidfile_from_conf: /etc/namedb/named.conf does not exist (named)
```
Checking:

```
root@server:/root # ls -l /var/named/etc/namedb/
total 40
drwxr-xr-x  2 bind  wheel    512 Dec  4 04:32 dynamic
drwxr-xr-x  2 root  wheel    512 Dec  4 04:34 master
-rw-r--r--  1 bind  wheel  15150 Jan 17 15:57 named.conf
-rw-r--r--  1 bind  wheel   3135 Dec  4 04:34 named.root
-rw-------  1 bind  wheel     97 Dec 22 03:49 rndc.key
drwxr-xr-x  2 bind  wheel    512 Dec  4 04:32 slave
drwxr-xr-x  2 bind  wheel    512 Jan 25 02:04 working
root@server:/root # cat /etc/defaults/rc.conf | grep named
# named.  It may be possible to run named in a sandbox, man security for
named_enable="NO"               # Run named, the DNS server (or NO).
named_program="/usr/sbin/named" # Path to named, if you want a different one.
named_conf="/etc/namedb/named.conf"     # Path to the configuration file
#named_flags=""                 # Use this for flags OTHER than -u and -c
named_uid="bind"                # User to run named as
named_chrootdir="/var/named"    # Chroot directory (or "" not to auto-chroot it)
named_chroot_autoupdate="YES"   # Automatically install/update chrooted
                                # components of named. See /etc/rc.d/named.
named_symlink_enable="YES"      # Symlink the chrooted pid file
named_wait="NO"                 # Wait for working name service before exiting
named_wait_host="localhost"     # Hostname to check if named_wait is enabled
named_auto_forward="NO"         # Set up forwarders from /etc/resolv.conf
named_auto_forward_only="NO"    # Do "forward only" instead of "forward first"
root@server:/root # cat /etc/rc.conf | grep named
named_enable="YES"
```
Cause:
FreeBSD 9.1 was running OK, but named fails today
Solution:

```
root@server:/etc # ln -s /var/named/etc/namedb /etc/namedb
root@server:/etc # /etc/rc.d/named start
Starting named.
```
I do not know what happened, any ideas ?


----------



## RedErick (Aug 30, 2013)

_I g_ot the same error ten minutes ago because of unexpected power loss (bad UPS). I think that this could be a file system error.


----------

