dnssec-keygen Command

Purpose

Domain name system security extensions (DNSSEC) key generation tool.

Syntax

dnssec-keygen [-a algorithm] [-b keysize] [-n nametype] [-c class] [-e] [-f flag] [-g generator] [-h] [-k] [-p protocol] [-r randomdev] [-s strength] [-t type] [-v level] [name]

Description

The dnssec-keygen command generates keys for DNSSEC (Secure DNS). It can also generate keys to use with Transaction Signatures (TSIG).

Flags

Item Description
-a algorithm Selects the cryptographic algorithm. The algorithm can have one of the following values:
  • RSAMD5
  • DSA
  • DH (Diffie-Hellman)
  • HMAC-MD5
These values are case-sensitive.
Notes:
  1. For DNSSEC, RSASHA1 is a mandatory-implement algorithm, and DSA is preferred. For TSIG, HMAC-MD5 is mandatory.
  2. HMAC-MD5 and DH automatically set the -k flag.
-b keysize Specifies the number of bits in the key. The choice of key size depends on the algorithm used. RSAMD5 and RSASHA1 keys must be 512 - 4096 bits. DH keys must be 128 - 4096 bits. DSA keys must be 512 - 1024 bits and an exact multiple of 64. HMAC-MD5 keys must be 1 - 512 bits.
-n nametype Specifies the owner type of the key. The value of nametype must either be ZONE (for a DNSSEC zone key), HOST, or ENTITY (for a key that is associated with a host), USER (for a key that is associated with a user), or OTHER (DNSKEY). These values are not case-sensitive.
-c class Indicates that the Domain Name Server (DNS) record that contains the key must have the specified class. If not specified, class IN is used.
-e If you are generating an RSAMD5 or RSASHA1 key, use a large exponent.
-f flag Sets the specified flag in the flag field of the KEY or the DNSKEY record. The only recognized flag is KSK (Key Signing Key) DNSKEY.
-g generator If you are generating a DH key, use this generator. The acceptable values are 2 and 5. If generator is not specified, a known prime from RFC 2539 is used if possible; otherwise the default is 2.
-h Prints a short summary of the options and arguments to the dnssec-keygen command.
-k Generates KEY records rather than DNSKEY records.
-p protocol Sets the protocol value for the generated key. The protocol is a number 0 - 255. The default is 3 (DNSSEC).
-r randomdev Specifies the source of randomness. If the operating system does not provide a /dev/random file or equivalent device, the default source of randomness is keyboard input. The randomdev argument specifies the name of a character device or a file that contains random data to be used instead of the default. The special value keyboard indicates that keyboard input must be used.
-s strength Specifies the strength value of the key. The strength argument is a number 0 - 15, and currently has no defined purpose in DNSSEC.
-t type Indicates the use of the key. The type must be one of AUTHCONF, NOAUTHCONF, NOAUTH, or NOCONF. The default is AUTHCONF. AUTH refers to the ability to authenticate data, and CONF the ability to encrypt data. No key is generated for these algorithms (DH, HMAC-MD5, HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384, HMAC-SHA512) with key type as NOAUTHCONF.
-v level Sets the debugging level.

Parameters

Item Description
name The name of the key that is specified on the command line. For DNSSEC keys, this name must match the name of the zone for which the key is being generated.

Generated Keys

When the dnssec-keygen command completes successfully, it prints a string of the form Knnnn.+aaa+iiiii to the standard output. It is an identification string for the key that it generated.
  • nnnn is the key name.
  • aaa is the numeric representation of the algorithm.
  • iiiii is the key identifier (or footprint).
The dnssec-keygen command creates two files with names based on the printed string: Knnnn.+aaa+iiiii.key contains the public key, and Knnnn.+aaa+iiiii.private contains the private key.

The .key file contains a DNSKEY record that can be inserted into a zone file (directly or with a $INCLUDE statement). The .private file contains algorithm-specific fields. For security reasons, this file does not have general read permission. Both the .key and .private files are generated for symmetric encryption algorithm such as HMAC-MD5, even though the public key and the private key are equivalent.

Examples

To generate a 768 - bit DSA key for the domain example.com, type the following command:
dnssec-keygen -a DSA -b 768 -n ZONE example.com
The command prints a string of the form:
Kexample.com.+003+26160
In this example, dnssec-keygen creates the files Kexample.com.+003+26160.key and Kexample.com.+003+26160.private.