Installing MyDNS-NG & MyDNSConfig On Debian Squeeze

This tutorial is an updated copy from Installing MyDNS-NG & MyDNSConfig 3 On Debian Lenny tutorial.

This tutorial will describe how to install and configure MyDNS-NG and MyDNSConfig 3 on Debian Squeeze. MyDNS-NG (based on MyDNS originally writen by Don Moore - is a DNS server that uses a MySQL database as backend instead of configuration files. The advantage is that MyDNS simply reads the records from the database, and it does not have to be restarted/reloaded when DNS records change or zones are created/edited/deleted. A secondary nameserver can be easily set up by installing a second instance of MyDNS that accesses the same database or, to be more redundant, uses the MySQL master / slave replication features to replicate the data to the secondary nameserver.

MyDNSConfig is an easy to use web-based interface to MyDNS-NG. MyDNSConfig can create all types of DNS records that are available in MyDNS and adds features like user management and access privileges.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

In this tutorial I use the hostname with the IP address These settings might differ for you, so you have to replace them where appropriate.


2 Installing MySQL

We can install MySQL as follows:

aptitude install mysql-client mysql-server

You will be asked the following questions:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword


3 Installing Apache2, PHP, phpMyAdmin

MyDNSConfig needs a web server with PHP support; therefore I install Apache2. I also install phpMyAdmin so that I can access the database later on over a web interface (although this is optional):

aptitude install apache2 apache2-mpm-prefork imagemagick mcrypt php5 php-auth php5-gd php5-imagick php5-imap php5-mcrypt php5-mysql php-pear phpmyadmin vlogger

You will see the following question:

Web server to reconfigure automatically: <-- apache2

Then run the following command to enable the Apache modules suexec, rewrite, ssl, actions, and include:

a2enmod suexec rewrite ssl actions include

Restart Apache afterwards:

/etc/init.d/apache2 restart

You can now access phpMyAdmin under or


4 Installing MyDNS

Before we install MyDNS, we need to install a few prerequisites:

aptitude install build-essential libmysqlclient-dev

MyDNS is not available in the Debian Squeeze repositories, therefore we have to build it ourselves as follows:

cd /tmp
tar xfz mydns-
cd mydns-
make install

Next we create the start/stop script for MyDNS:

vi /etc/init.d/mydns

#! /bin/sh
# mydns Start the MyDNS server
# Author: Philipp Kern <>.
# Based upon skeleton 1.9.4 by Miquel van Smoorenburg
# <> and Ian Murdock <>.

set -e

DESC="DNS server"


# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

case "$1" in
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet \
--exec $DAEMON -- -b
echo "."
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --stop --oknodo --quiet \
--exec $DAEMON
echo "."
echo -n "Reloading $DESC configuration..."
start-stop-daemon --stop --signal HUP --quiet \
--exec $DAEMON
echo "done."
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --stop --quiet --oknodo \
--exec $DAEMON
sleep 1
start-stop-daemon --start --quiet \
--exec $DAEMON -- -b
echo "."
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
exit 1

exit 0

Then we make the script executable and create the system startup links for it:

chmod +x /etc/init.d/mydns
update-rc.d mydns defaults

Share this page:

5 Comment(s)

Add comment


From: cimnine at: 2011-02-21 17:20:02

I've updated the init script to support the new dependency boot introduced with debian squeeze.

 You find it here: (and if the server does not answer, the script probably did not work ;) )

 Cheers, Chris

From: at: 2011-12-07 14:48:13

This indeed fixes all crap of mydns trying to start before mysql. As you mentioned :

# Provides:          mydns
# Required-Start:    $local_fs $network $syslog
# Required-Stop:     $local_fs $network $syslog
# Should-Start:	     mysql
# Should-Stop:       mysql
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start and stop MyDNS
# Description:       MyDNS is a DNS Daemon using an SQL database as backend.
This fixes all the hassle of mydns trying to start before mysql. Thanks for sharing.

From: Anonymous at: 2011-02-06 10:14:58

Nice howto, but this project is dead. Last update was in 2006. The server itself doesn't provide basic functions necessary for corporate DNS (like automatic updates of local zones from DHCP) and its security is unknown (untested by large number of users).

Stay away from it, investing the time in it is a dead end.

From: at: 2011-05-30 20:59:38

Why do you say that? Please have a look in



Dec 24, 2010
New release [ changes ]
- MyDNS-NG stops responding after some time. Thank you Thomas! #40
- Delegation now has precedence over wildcard matching, fixes bugs #38 & #42
- Fix for NAPTR.#23
- Add patch to show SOA box's in red when inactive.#27

Mar 26, 2009
New release [ changes ]
This release fixes a bug in the recursion code. This bug would have caused at least one of the 100% CPU bugs that have been seen recently.

Feb 22, 2009

From: iser0073 at: 2011-07-26 01:08:00

Hey Guys, Thanx for this tutorial!

 I notice that when editing /tmp/mydnsconfig/install/lib/install.lib.php


You need to first check what your current debian version is, do this by running:

cat /etc/debian_version

At the moment it's 6.0.2, so copying the script above no longer works.

 Fix it by replacing the line:

if(trim(file_get_contents('/etc/debian_version')) == '6.0' || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {

With the following line:

if(trim(file_get_contents('/etc/debian_version')) == '6.0.2' || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {

And make sure the version matches your current debian version.