Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Postfix "Client host rejected: cannot find your hostname": reject_unknown_client_hostname

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When Postfix applies reject_unknown_client_hostname, a client that fails forward-confirmed reverse DNS is rejected. The SMTP reply text from Postfix's smtpd_check.c is Client host rejected: cannot find your hostname, [%s] with enhanced status 4.7.25 on every such reject. The numeric SMTP code is unknown_client_reject_code (default 450) on the permanent path, or always 450 when the mapping failed as a temporary problem; only that numeric code differs, not 4.7.25.

What the symptom means

postconf(5) defines reject_unknown_client_hostname (older name reject_unknown_client) as rejecting when:

  1. the client IP address→name mapping fails, or
  2. the name→address mapping fails, or
  3. the name→address mapping does not match the client IP address.

It is stronger than reject_unknown_reverse_client_hostname, which triggers only when the address→name mapping fails. unknown_client_reject_code defaults to 450. The reply is always 450 when the mapping failed because of a temporary problem.

The related reverse-only restriction uses the different text Client host rejected: cannot find your reverse hostname, [%s] with enhanced status 4.7.1 in the same source file. Read the log line before you change DNS.

Likely causes

Cause What you see How to confirm
No PTR for the client IP Reject with cannot find your hostname; dig -x empty dig -x the client IP from the reject line
PTR name has no A/AAAA Same reject; warning that hostname does not resolve dig A/AAAA for the PTR name
A/AAAA does not match the client IP Same reject; forward IP differs Compare dig result with the IP in brackets
Restriction placed before permit_sasl_authenticated Authenticated submitters also rejected postconf smtpd_client_restrictions

Prove the cause before changing anything

All of these are read-only.

1. Copy the reject line from the mail log, including the IP in brackets.

2. Query reverse DNS:

dig -x <client-ip> +short

3. Query forward DNS for the PTR name:

dig +short A <ptr-name>
dig +short AAAA <ptr-name>

4. List the restriction:

postconf smtpd_client_restrictions smtpd_recipient_restrictions unknown_client_reject_code

Fix

Prefer fixing DNS for the sending IP. Soften the restriction only when you accept the spam trade-off.

Repair forward-confirmed reverse DNS

Save the current PTR and forward answers first:

dig -x <client-ip> +short > ptr-before.txt
dig +short A <mail-hostname> > a-before.txt

Risk: the next change publishes a new PTR and/or A/AAAA for the sending IP and hostname. Wrong values break reverse checks at every receiver that requires them, not only at this Postfix server, until you put the previous values back.

At the provider that controls reverse DNS for the IP, set the PTR to the mail hostname. At the DNS zone for that hostname, set A/AAAA to the same IP. Wait for TTL, then retest.

To undo it: restore the PTR and A/AAAA from ptr-before.txt and a-before.txt.

Adjust Postfix restrictions

Save the active restrictions first:

postconf -n smtpd_client_restrictions > smtpd-client-restrictions-before.txt

Risk: the next commands change smtpd_client_restrictions and reload Postfix. A postconf -e assignment replaces the entire parameter value, so any other entries you had are dropped unless you copy them into the new string. A mistaken permit can open relay paths you did not intend; a mistaken reject can defer or refuse legitimate mail until you restore the previous setting.

Take the saved list from smtpd-client-restrictions-before.txt and add permit_mynetworks and, if you use submission auth, permit_sasl_authenticated before reject_unknown_client_hostname, keeping every other entry you still need. Set that full list back, for example:

postconf -e 'smtpd_client_restrictions = <full saved list with permit_mynetworks and permit_sasl_authenticated before reject_unknown_client_hostname>'
postfix reload

To undo it: set smtpd_client_restrictions back to the exact value in smtpd-client-restrictions-before.txt and run postfix reload again. If that file is empty because the parameter was still at its default, run postconf -X smtpd_client_restrictions and then postfix reload (postconf(1) documents -X for deleting a parameter from main.cf).

Example (illustrative): A customer IP 198.51.100.20 has PTR mail.example.net but mail.example.net A points to 203.0.113.20. Postfix rejects with 450 4.7.25 Client host rejected: cannot find your hostname, [198.51.100.20]. Aligning the A record with 198.51.100.20 clears the reject without removing the restriction.

Confirm the fix

  1. dig -x and forward dig show a matching pair for the client IP.
  2. A new message from that IP is accepted (or reaches a later restriction).
  3. postconf smtpd_client_restrictions still matches what you intended.

What to watch afterwards

  • On many cloud hosts, setting PTR needs a panel or support request; the A record alone is not enough (general experience, not a cited-page statement).
  • IPv6 needs its own PTR and AAAA pair.
  • warn_if_reject reject_unknown_client_hostname can log what would be rejected before you enforce it.

Risks and limits

  • Removing reject_unknown_client_hostname increases acceptance of clients without FCrDNS.
  • Temporary DNS failures force numeric 450 even when you set a permanent unknown_client_reject_code.
  • These Postfix and DNS steps have not been lab-tested.

Sources