DNS

DNS 20 BADNAME vs 22 BADTRUNC

Both DNS 20 (BADNAME) and 22 (BADTRUNC) belong to the DNS Response Codes (RCODEs) category. 20 indicates that duplicate key name. The key name in a TKEY negotiation is already in use or conflicts with an existing key. Meanwhile, 22 means that bad truncation. The TSIG record was truncated in a way that makes it impossible to verify the message signature.

Description

Duplicate key name. The key name in a TKEY negotiation is already in use or conflicts with an existing key.

When You See It

A TKEY key establishment failed because a key with the same name already exists on the server from a previous session that was not properly cleaned up.

How to Fix

Use a unique key name for each TKEY session (e.g., append a timestamp or random suffix). Delete stale keys on the server if they are no longer needed.

Description

Bad truncation. The TSIG record was truncated in a way that makes it impossible to verify the message signature.

When You See It

A large DNS response was truncated (TC bit set) but the TSIG MAC was computed over the full message, making the truncated version unverifiable.

How to Fix

Retry the query over TCP to avoid truncation. If using UDP, ensure your EDNS buffer size is large enough to receive the full signed response.

Key Differences

1.

DNS 20: Duplicate key name. The key name in a TKEY negotiation is already in use or conflicts with an existing key.

2.

DNS 22: Bad truncation. The TSIG record was truncated in a way that makes it impossible to verify the message signature.

3.

You encounter 20 when a TKEY key establishment failed because a key with the same name already exists on the server from a previous session that was not properly cleaned up.

4.

You encounter 22 when a large DNS response was truncated (TC bit set) but the TSIG MAC was computed over the full message, making the truncated version unverifiable.

When to Use Which

For 20 (BADNAME): Use a unique key name for each TKEY session (e.g., append a timestamp or random suffix). Delete stale keys on the server if they are no longer needed. For 22 (BADTRUNC): Retry the query over TCP to avoid truncation. If using UDP, ensure your EDNS buffer size is large enough to receive the full signed response.

Learn More