Q. How do I monitor my BIND 9 (named) server with monit which is chrooted at /var/lib/named directory? How do I restart bind (named) server if it does not respond or dead due to any issues under Debian / Ubuntu Linux?

A. You can easily restart or send alert when bind9 is not responding under Debian / Ubuntu or UNIX like operating system using monit.

Restart named (bind9) if does not respond to port 53

Open monitrc file, enter:
# vi /etc/monit/monitrc
Append following code, enter:

## bind
check process named with pidfile /var/lib/named/var/run/bind/run/named.pid
 start program = "/etc/init.d/bind9 start"
 stop program = "/etc/init.d/bind9 stop"
 if failed host 127.0.0.1 port 53 type tcp protocol dns then restart
 if failed host 127.0.0.1 port 53 type udp protocol dns then restart
 if 5 restarts within 5 cycles then timeout

A note about RHEL / CentOS / Red Hat / Fedora Linux

You need following code for RHEL, enter:

## bind
check process named with pidfile /var/named/chroot/var/run/named/named.pid
 start program = "/etc/init.d/named start"
 stop program = "/etc/init.d/named stop"
 if failed host 127.0.0.1 port 53 type tcp protocol dns then restart
 if failed host 127.0.0.1 port 53 type udp protocol dns then restart
 if 5 restarts within 5 cycles then timeout

Save and close the file. Restart monit, enter:
# /etc/init.d/monit restart


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum