Install and chroot bind9 on debian 7.6

Installation

Start with installing bind9.

apt-get install bind9

Stop bind and prepare to chroot it.

/etc/init.d/bind9 stop

Edit /etc/default/bind9

# run resolvconf?
RESOLVCONF=no

# startup options for the server
OPTIONS="-u bind -t /var/lib/named"

Create the new directories under /var/lib.
Move the bind-files and creating symbolic-links to them.


mkdir -p /etc/bind/zones
mkdir -p /var/lib/named/etc
mkdir /var/lib/named/dev
mkdir -p /var/lib/named/var/cache/bind
mkdir -p /var/lib/named/var/run/bind/run
mv /etc/bind /var/lib/named/etc
ln -s /var/lib/named/etc/bind /etc/bind

Make null and random devices and set permissions

mknod /var/lib/named/dev/null c 1 3
mknod /var/lib/named/dev/random c 1 8
chmod 666 /var/lib/named/dev/null /var/lib/named/dev/random
chown -R bind:bind /var/lib/named/var/*
chown -R bind:bind /var/lib/named/etc/bind

Make bind able to report to syslog.
Create and edit /etc/rsyslog.d/bind-chroot.conf


$AddUnixListenSocket /var/lib/named/dev/log

Restart syslog

/etc/init.d/rsyslog restart

Start bind

/etc/init.d/bind9 start