Table of Contents#
- What is
dnssec-keygen? - Syntax of
dnssec-keygen - Common Practices
- Best Practices
- Example Usage
- References
1. What is dnssec-keygen?#
dnssec-keygen is a command-line utility in Linux (part of the BIND utilities, e.g., the bind9utils or bind-utils package depending on your distribution) that generates public and private key pairs for DNSSEC. These keys are used to sign DNS records, ensuring the authenticity and integrity of DNS data.
2. Syntax of dnssec-keygen#
The basic syntax of dnssec-keygen is as follows:
dnssec-keygen [options] <domain>Options#
-a <algorithm>: Specify the algorithm for key generation. Common algorithms includeRSASHA256,RSASHA512, etc.-b <bits>: Set the key size in bits. For example,-b 2048for a 2048-bit key.-c <class>: Define the DNS class (usuallyINfor Internet).
3. Common Practices#
Key Size Selection#
- Smaller Domains: For domains with relatively low traffic and security requirements, a 2048-bit key (using an appropriate algorithm like
RSASHA256) might be sufficient. - High-Security Domains: For critical domains (e.g., financial institutions), a 4096-bit key with a stronger algorithm like
RSASHA512is often recommended.
Algorithm Choice#
RSASHA256: Widely supported and a good balance between security and performance.RSASHA512: Offers higher security but may have slightly more computational overhead.
4. Best Practices#
Key Rotation#
- Regularly rotate keys (e.g., every 6 - 12 months). This helps mitigate the risk of key compromise. Use tools like
dnssec-signzonein combination withdnssec-keygenfor a smooth key rotation process. - Keep a backup of old keys for a reasonable period (e.g., 3 - 6 months after rotation) in case there are issues with the new keys.
Secure Storage#
- Store the private keys in a secure location (e.g., an encrypted filesystem or a hardware security module if available). Only authorized personnel should have access to the private keys.
5. Example Usage#
Example 1: Generate a Basic Key#
Let's generate a 2048-bit RSASHA256 key for the domain example.com.
dnssec-keygen -a RSASHA256 -b 2048 example.comAfter running this command, you'll see output like:
Kexample.com.+008+12345
Here, Kexample.com is the key file prefix. The actual key files generated will be:
Kexample.com.+008+12345.key(public key)Kexample.com.+008+12345.private(private key)
Example 2: Generate a Key with a Specific DNS Class#
Suppose we want to generate a key for a domain in the CH (Chaos) class (although this is less common than IN).
dnssec-keygen -a RSASHA256 -b 2048 -c CH example.comExample 3: Key Rotation Preparation#
First, generate a new key (let's say for example.com again). Assume we've been using a 2048-bit RSASHA256 key and now want to upgrade to a 4096-bit RSASHA512 key.
dnssec-keygen -a RSASHA512 -b 4096 example.comThen, use dnssec-signzone to gradually introduce the new key into the zone signing process, while still keeping the old key for a transition period.
6. References#
This blog post has provided a detailed overview of the dnssec-keygen command in Linux. By following the common and best practices and using the example usages, you can effectively manage DNSSEC keys for your domains.