Source

mindref-sbin / chroot-bind9

#!/bin/bash

/etc/init.d/bind9 stop

mkdir -p /var/chroot/bind9/{etc,dev,var/cache/bind,var/run/bind/run}
chown -R bind:bind /var/chroot/bind9/var/*

mknod /var/chroot/bind9/dev/null c 1 3
mknod /var/chroot/bind9/dev/random c 1 8
chmod 666 /var/chroot/bind9/dev/{null,random}

mv /etc/bind /var/chroot/bind9/etc
ln -s /var/chroot/bind9/etc/bind /etc/bind

chown -R bind:bind /etc/bind/*
chmod -R g+w /etc/bind/

echo "\$AddUnixListenSocket /var/chroot/bind9/dev/log" > /etc/rsyslog.d/bind-chroot.conf

sed -e 's,"-u bind","-u bind -t /var/chroot/bind9",' /etc/default/bind9 > /tmp/x && mv /tmp/x /etc/default/bind9

/etc/init.d/bind9 start