Code: Select all
mkdir /var/chroot
emerge --config =net-dns/bind-9.16.42 ### specify your version.
/etc/init.d/named restart ####in your case systemctl restart named
#### for me it failed here complaining there is no named.conf in chroot.So I did
cp -pa /var/bind/* /var/chroot/bind/var/bind/
cp -pa /etc/bind/* /var/chroot/bind/etc/bind/
/etc/init.d/named restart #### systemctl restart named
###It worked.
Code: Select all
emerge --config =net-dns/bind-9.16.42 ### ignore the error about failing to UNSET CHROOT
/etc/init.d/named restart ####in your case systemctl restart named
reboot
Code: Select all
rm -rf /var/chroot/bind
Code: Select all
CHROOT="/named"
Code: Select all
emerge --config =net-dns/bind-9.16.42
Code: Select all
#!/bin/bash
_mount() {
from="$1"
to="$2"
# Check if mounted, else mount
if ! mountpoint -q "$to"; then
mount "$from" "$to" -o bind
fi
}
# Mount the directories
_mount "/etc/bind" "/named/etc/bind"
_mount "/var/bind" "/named/var/bind"
_mount "/var/log/named" "/named/var/log/named"
Code: Select all
#!/bin/bash
_unmount() {
mount_point="$1"
# Check if mounted and unmount
if mountpoint -q "$mount_point"; then
umount "$mount_point"
fi
}
# Unmount directories
_unmount "/named/etc/bind"
_unmount "/named/var/bind"
_unmount "/named/var/log/named"
Code: Select all
[Service]
ExecStartPre=
ExecStartPre=/usr/local/bin/bindmount.sh
ExecStartPre=/usr/libexec/generate-rndc-key.sh
ExecStartPre=/usr/sbin/named-checkconf -z /etc/bind/named.conf
ExecStart=
ExecStart=/usr/sbin/named -t /named -u named -f
ExecStop=
ExecStop=/usr/sbin/rndc stop
ExecStopPost=/usr/local/bin/bindunmount.sh