On a recent server install I needed to put djbdns onto an Ubuntu 20.04 system. djbdns is no longer support by Bernstein, but it has been in the public domain for a few years now. Note that djbdns is not really supported any more. So anyone setting up a new dns server should likely look at other options. If you are an old djbdns user and need other servers to use it to maintain compatibility or your sanity then this should get you where you want to be.
The author of another DNS package, MaraDNS,has kindly taken it upon himself to maintain (minimally) djbdns as outlined here.
He put the updated djbdns package on GitHUB here: https://github.com/samboy/ndjbdns Note this is based on a fork on the more modern ndjbdns.
So why do you need this blog posting? Well, the directions there are not quite up to date. Here is my take on it:
How-to Install djbdns in 2021 on Ubuntu 20.04
Grab the source from the GitHUB page. Either use git or svn to check out the sources, or download the Zip file– direct link here.
Expand the zip file, cd into the directory, and then run:
./configure
make
sudo make install
By default configure will set you up to install into /usr/local/. This works fine.
Note: I had to install g++ to appease configure (apt install g++) even though djb uses C.
Now you have both the dnscache caching server and the tinydns authoritative server installed, but not set to actually run. This is where the instructions on the GitHUB page fell apart.
Configure tinydns
Go ahead and configure tinydns settings using the conf file (unlike the old djbdns where you touch files to control settings this new version has conf files):
sudo nano /usr/local/etc/ndjbdns/tinydns.conf
Note that the GitHUB package has the UID and GID set to number 2, attempting to run as the user daemon. On my Ubuntu install the daemon users is uid/gid number 1. So I had to change these both to 1. (grep daemon /etc/passwd and grep daemon /etc/group to see what yours are.) You may also opt to create your own user and group specifically for djb.
Don’t forget to put your data file and make your data.cdb file in the directory specified in the conf file (by default they go in /usr/local/etc/ndjbdns/ ). Make sure these are readable and writable by the user you specified in the conf file (daemon).
Make tinydns run from systemd
If you want to run tinydns, the authoritative nameserver you need to set it to run with systemd. The GitHUB package does include service settings for systemd. It puts them in /usr/local/lib/systemd/system/. So you need to create a symlink to actually activate the service:
sudo ln -s /usr/local/lib/systemd/system/tinydns.service /etc/systemd/system/tinydns.service
Now reload systemd:
sudo systemctl daemon-reload
Enable tinydns service in systemd:
sudo systemctl enable tinydns
And start it up:
sudo systemctl start tinydns
Check the status to make sure it is running:
sudo systemctl status tinydns
Configure dnscache
Go ahead and configure dnscache settings using the conf file (unlike the old djbdns where you touch files to control settings this new version has conf files):
sudo nano /usr/local/etc/ndjbdns/dnscache.conf
Note that the GitHUB package has the UID and GID set to number 2, attempting to run as the user daemon. On my Ubuntu install the daemon users is uid/gid number 1. So I had to change these both to 1. (grep daemon /etc/passwd and grep daemon /etc/group to see what yours are.) You may also opt to create your own user and group specifically for djb.
Make dnscache run from systemd
If you want to run dnscache, the caching name server you need to set it to run with systemd. The GitHUB package does include service settings for systemd. It puts them in /usr/local/lib/systemd/system/. So you need to create a symlink to actually activate the service:
sudo ln -s /usr/local/lib/systemd/system/dnscache.service /etc/systemd/system/dnscache.service
Now reload systemd:
sudo systemctl daemon-reload
Enable dnscache service in systemd:
sudo systemctl enable dnscache
And start it up:
sudo systemctl start dnscache
Check the status to make sure it is running:
sudo systemctl status dnscache
Conclusion
For anyone needing to run djbdns on modern Ubuntu like 20.04 hopefully this got you going. For anyone considering setting up a new machine with djbdns– don’t. It is barely supported at this stage. You are better off with BIND (I know) or other more modern name servers.
Thank you to Sam Trenholme, the author of MaraDNS, and the kind soul who has decided to keep djbdns on life support for the community.
Life saver post. Thanks.
Glad it helped.