Add bind9 to an already installed hestia

hello!
can you add bind9 to an already installed hestia?
thanks

Install bind9
apt-get install bind9

Then append it to hestia.conf
echo “DNS_SYSTEM=‘bind9’” >> $HESTIA/conf/hestia.conf

Run the following commands:

And it should work fine

3 Likes

A little help to implement this github code from the terminal? I can’t seem to add those commands successfully. I also need to add bind9 on a server with Hestia already installed.

Thanks!

This script should install and configure bind9. Download it to a file, give exection perms to the file and execute as root.

#!/usr/bin/env bash
HESTIA='/usr/local/hestia'
HESTIA_INSTALL="$HESTIA/install/deb"
HESTIA_BIN="$HESTIA/bin"

# Installing bind9
echo "Installing bind9"
apt install bind9 apparmor-utils -y

# Check if apparmor is installed
if [ "$(dpkg-query -W -f='${Status}' apparmor 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
        apparmor='no'
else
        apparmor='yes'
fi

# Configuring bind9 for Hestia
echo "[ * ] Configuring Bind DNS server..."
cp -f "$HESTIA_INSTALL/bind/named.conf" /etc/bind/
cp -f "$HESTIA_INSTALL/bind/named.conf.options" /etc/bind/
chown root:bind /etc/bind/named.conf
chown root:bind /etc/bind/named.conf.options
chown bind:bind /var/cache/bind
chmod 640 /etc/bind/named.conf
chmod 640 /etc/bind/named.conf.options
aa-complain /usr/sbin/named 2>/dev/null
if [ "$apparmor" = 'yes' ]; then
        echo "/home/** rwm," >>/etc/apparmor.d/local/usr.sbin.named 2>/dev/null
        if ! systemctl status apparmor >/dev/null 2>&1; then
                systemctl restart apparmor
        fi
fi
/usr/sbin/update-rc.d bind9 defaults
if ! systemctl start bind9; then
        echo "bind9 start failed"
fi
"$HESTIA_BIN/v-change-sys-config-value" DNS_SYSTEM bind9
echo "Done"

I get the following output

[ * ] Configuring Bind DNS server...
cp: cannot stat '/usr/local/hestia/install/bind/named.conf': No such file or directory
cp: cannot stat '/usr/local/hestia/install/bind/named.conf.options': No such file or directory
./runbind: line 33: update-rc.d: command not found
/usr/local/hestia/func/main.sh: line 1582: declare: `“DNS_SYSTEM=‘bind9’”': not a valid identifier
/usr/local/hestia/func/main.sh: line 1582: declare: `“DNS_SYSTEM=‘bind9’”': not a valid identifier

However, bind9 appears to be installed from the hestia interface.

Regarding this, my bad, used the wrong path.

Execute these commands as root:

cp -f "/usr/local/hestia/install/deb/bind/named.conf" /etc/bind/
cp -f "/usr/local/hestia/install/deb/bind/named.conf.options" /etc/bind/
chown root:bind /etc/bind/named.conf
chown root:bind /etc/bind/named.conf.options
chown bind:bind /var/cache/bind
chmod 640 /etc/bind/named.conf
chmod 640 /etc/bind/named.conf.options

How did you execute the script? Using sudo?

Execute this:

/usr/sbin/update-rc.d bind9 defaults

What version of Hestia are you using?

Could you please execute again the command?

/usr/local/hestia/bin/v-change-sys-config-value" DNS_SYSTEM bind9

if it gives an error again, show the output of this command:

grep -i dns /usr/local/hestia/conf/hestia.conf

No. I ran from root. runbind is the file where I copied the script.

I get the following output:
update-rc.d: error: unable to read /etc/init.d/bind9

Hestia Control Panel v1.8.11

I get the following output:

>

And the following command…

grep -i dns /usr/local/hestia/conf/hestia.conf

give me…

DNS_CLUSTER_SYSTEM='hestia'
“DNS_SYSTEM=‘bind9’”
“DNS_SYSTEM=‘bind9’”
“DNS_SYSTEM=‘bind9’”
...
“DNS_SYSTEM=‘bind9’”
DNS_SYSTEM='bind9'
POLICY_USER_EDIT_DNS_TEMPLATES='yes'
“DNS_SYSTEM=‘bind9’”
...
“DNS_SYSTEM=‘bind9’”
“DNS_SYSTEM=‘bind9’”

I shouldn’t try to scripting after 23:00 :stuck_out_tongue:

Ok, the right command is with named instead of bind9

/usr/sbin/update-rc.d named defaults

The double quote must be removed

/usr/local/hestia/bin/v-change-sys-config-value DNS_SYSTEM bind9

But don’t execute it again, there is no need to do that.

I don’t know what happened there but you must edit the file and remove all these entries: “DNS_SYSTEM=‘bind9’”

The righ one is DNS_SYSTEM=‘bind9’ without double quotes.

Sometimes 11:00 is worse :joy:

I’m curious, so I ran it again and got the following output:

/usr/local/hestia/func/main.sh: line 1582: declare: `“DNS_SYSTEM=‘bind9’”': not a valid identifier

It looks like a string is being passed in a place where it’s not expected.
Now, is there any way to check that bind9 is finally installed correctly with Hestia?

Thanks!

But did you remove the other lines before execute the command again?

That’s it. The mistake was mine, putting code where it didn’t belong while I was testing without fear or conscience. :face_with_peeking_eye:

The command now proceeds cleanly with no response. So… Is there any way to check that bind9 is finally installed correctly with Hestia?

1 Like

From Web UI add a dns zone for one of your domains

All OK.

Thanks for your time @sahsanu :slight_smile:

1 Like