OpenDnsSec on Debian with Bind

I had posted about dnssec a few months ago but that was using some quite cumbersome method to deploy DNS Security to your DNS. I have since looked at OpenDNSSEC which is a more suitable and easier solution. Here are my steps to make it work on Debian.

Big Fat Warning: Test this at your own risk, do not deploy in live setups unless you know what you are doing, this will eat kittens and increase your carbon tax. Still reading? Carry on then.

I am using Debian Wheezy (testing) for this DNS setup because the OpenDNSSEC packages are more up to date. Start off by installing the required packages: apt-get install opendnssec libhsm-bin softhsm libsofthsm libhsm-bin. Then you can start on configuring it. All files are under /etc/opendnssec.

Edit the following file: conf.xml (change your PIN with your own):

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: 3192 2010-04-14 20:51:42Z rb $ -->

                <Repository name="SoftHSM">
                <NotifyCommand>/usr/sbin/rndc reload %zone</NotifyCommand>


Then edit kasp.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: 3564 2010-07-06 13:39:29Z rb $ -->
        <Policy name="default">
                <Description>A default policy that will amaze you and your friends</Description>
                                <!-- <OptOut/> -->
                                        <Salt length="8"/>
                        <!-- Parameters for both KSK and ZSK -->
                        <!-- <ShareKeys/> -->

                        <!-- Parameters for KSK only -->
                                <Algorithm length="2048">7</Algorithm>

                        <!-- Parameters for ZSK only -->
                                <Algorithm length="1024">7</Algorithm>
                                <!-- <ManualRollover/> -->
                        <!-- <Partial /> -->

Edit the following file /etc/softhsm/softhsm.conf then add:


We can now create the database, it will ask for you PIN, this is the one declared in your first configuration file. Execute the following: softhsm –init-token –slot 1 –label “OpenDNSSEC”

Edit your groups file to match the following:


You can now setup the database by doing the following: ods-ksmutil setup

I recommend doing the following to set permissions right and linking the new signed/unsigned directories for OpenDNSSEC.

chown -R opendnssec:opendnssec /var/lib/opendnssec/
chgrp opendnssec /etc/opendnssec/*
ln -s /var/lib/opendnssec/signed /etc/bind/master/
ln -s /var/lib/opendnssec/unsigned /etc/bind/master/

This is now the exciting bit, we are adding our first zone, copy it under /var/lib/opendnssec/unsigned then do:

ods-ksmutil zone add -z
service opendnssec-enforcer restart
service opendnssec-signer restart

If you have done it right, it will tell you that it found your zone. If this is the case, it is now time to declare it in order to generate keys: ods-ksmutil key generate –policy default –interval 30. At this stage, you have to wait for the zone to become valid, this takes around 12h depending on what you setup. Time to make yourself a few coffees and listen to a few metal albums.

You now need to ready your zones. Rather than doing it manually, here is a script you can use (make sure you put it in the right folder):

ods-ksmutil  key list |grep ready|awk '{ print $1 }'  > list
for i in `cat list`;
SERIAL=`ods-ksmutil key export --zone $i --keystate ready |awk '{ print $11 }'`
ods-ksmutil key ds-seen -z $i -x $SERIAL

Now that the zone is ready, you need to get ods to sign it, this is just done by service opendnssec-signer restart. If it worked, you should see your new signed zone in /etc/bind/master/signed. All you got to do now is to change your bind config to point to the newly signed file.

We are now at the end of this article, it should be pointed out that keys expire, your Zone Signing Key (ZSK) expires after 6 months and the KSK after a year, you should plan for regenerating keys before the expiry if possible, since you are supposed to propagate these to the internet to establish the chain of trust from the root servers.

When you are modifying a zone, just trigger ods-signer sign to re-sign it. If you need to delete a zone within ods, you can use the following: ods-ksmutil zone delete –zone

At this time of writing please note that only a FEW root zones are signed, so this is more research than production (although all my zones are currently signed).

2 thoughts on “OpenDnsSec on Debian with Bind

  1. Recent versions of BIND will also do inline zone signing via dynamic updates. You need to handle key rollovers separately though.

  2. Nice, must read about that, although in my case, I am using a stealth master then pushing the signed zones to the official external master.

Comments are closed.