Aller au contenu
Email Authentication

Fix “opendkim-testkey: unexpected reply class/type (-1/-1)”

Add Nameservers 1.1.1.1,1.0.0.1 to /etc/opendkim.conf, restart opendkim, and run opendkim-testkey -d example.com -s default -vvv until it says “key OK”.

Testé sur Ubuntu 22.04 LTS, OpenDKIM 2.11

While setting up DKIM signing with OpenDKIM you run the key test and get:

Error
opendkim-testkey: 'default._domainkey.example.com' unexpected reply class/type (-1/-1)

The DKIM key itself is usually fine. The error means OpenDKIM’s own DNS lookup failed – it couldn’t get any answer, so it can’t compare the published key with your private key.

Step 1 – Give OpenDKIM working resolvers

Terminal
sudo nano /etc/opendkim.conf

Add (or edit) the Nameservers line:

/etc/opendkim.conf
Nameservers 1.1.1.1,1.0.0.1

Separate addresses with commas and no spaces. You can list more, e.g. 1.1.1.1,1.0.0.1,8.8.8.8,8.8.4.4.

Step 2 – Restart OpenDKIM

Terminal
sudo systemctl restart opendkim

Step 3 – Test the key

Terminal
sudo opendkim-testkey -d example.com -s default -vvv

Replace example.com and the selector (default) with yours. Success looks like:

Expected output
opendkim-testkey: key OK

“key not secure” just means the zone isn’t DNSSEC-signed – it’s normal and not an error.

Still failing? Check these

  • Is the record published? dig +short TXT default._domainkey.example.com should return your v=DKIM1; k=rsa; p=… record.
  • DNS propagation – new records can take time to appear, depending on TTL and provider (some providers publish within a minute).
  • Firewall – the server must be able to query outside DNS on UDP and TCP port 53.
  • Logs – sudo journalctl -u opendkim --since "10 min ago"

Check it from outside

The SPF, DKIM & DMARC Checker looks up your DKIM selector from the public internet, along with SPF and DMARC.

Inder Kochar

Écrit par

Inder Kochar

Ingénieur systèmes et réseaux – Je rédige les solutions que j’applique chez mes clients, testées sur de vrais systèmes. Bloqué sur un problème similaire ?

Continuer la lecture

Posez une question ou partagez votre solution

Votre e-mail n’est pas publié. Les commentaires sont modérés – merci de rester dans le sujet.