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

NetLeverage
NetLeverage

Exim: Unrouteable address, and MX records that point nowhere

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.

Exim bounced the address because routing finished without a router accepting it, or because the DNS data it did find cannot be used. Those are different faults. The default text for the first one, on the router option cannot_route_message, is "Unrouteable address". The chapter on how Exim receives and delivers mail describes the same event as bounced unrouteable, and it writes the default message as "unrouteable address". A second, more specific sentence is the one in FAQ Q0302: Exim says all relevant MX records point to non-existent hosts. A third is FAQ Q0301: the lowest numbered MX record points to the local host.

Read the sentence in the bounce or in the address test. Then change the DNS or the router that sentence is about.

What the symptom means

Routers run in order. If none accepts the address, chapter 3 says it is bounced as unrouteable, and the default message there is "unrouteable address". The option cannot_route_message sets that text when Exim has run out of routers. Its default message is "Unrouteable address". The value used is taken from the last router that was considered, including one that was skipped or that declined. It applies on a router with more set false, or on the last router.

The dnslookup router declines, instead of accepting, when an MX record points to a non-existent host, or when an MX record points to an IP address and allow_mx_to_ip is not set. FAQ Q0302 says MX records cannot point to IP addresses. They are defined to point to host names, so Exim always interprets them that way, and the FAQ notes that an IP address is a syntactically valid host name. The FAQ calls that DNS misconfigured. allow_mx_to_ip exists so Exim can accept the broken form. It does not make the record legal.

"Lowest numbered" is the MX preference. Chapter 17 says records that point at the local host are discarded unless they have the highest priority (lowest MX value). If that top-priority host is the local host, the self option decides. FAQ Q0301 says "lowest numbered MX record points to local host" means Exim expected a remote host and got this machine. The domain may need to be local, this host may be a hub, or the DNS should not point here.

A defer such as "retry time not reached" is not this bounce. A router accepted the address, and delivery is waiting.

Likely causes

Cause What you see How to confirm
No router accepts the domain Unrouteable address, and -bt shows every router declining or being skipped Address test
The MX target has no address records all relevant MX records point to non-existent hosts dig the MX, then dig each target
The MX target is an IP address written where a name belongs The same non-existent-host sentence. FAQ Q0302 The MX data looks like a dotted address
The lowest-numbered MX is this machine lowest numbered MX record points to local host FAQ Q0301. Check whether the domain should be local or hubbed

Prove the cause before changing anything

All of these are read-only.

1. Test the address. The -bt option runs address testing. Each argument is a recipient address, and the result is written to the standard output. Routers with no_address_test set are skipped. The return code is 2 if any address failed outright.

exim -bt user@example.com

If you are not an admin user and the test fails, the Exim command line chapter says no details are printed, because they might contain sensitive data. Run the test as an admin user when you need the router trace.

2. Read the MX and the targets. The dig manual takes a name and a type:

dig example.com MX

Then look up each host name on the right-hand side. A target that is a dotted address is the case in FAQ Q0302. A target with no A or AAAA record is a non-existent host in the dnslookup list.

3. See whether the lowest-numbered MX is you. Chapter 17 discards other MX records that point at the local host, and then applies self if the top-priority one is local. Compare that host's addresses with this machine before you edit a router.

Fix

Two different things can be wrong, and each has its own change below. If the MX data is wrong and you publish the zone, the MX has to name a host that has address records. If the domain should be local, a local router has to accept it before dnslookup, and FAQ Q0301 says to check the domains settings on the routers. If this host is a mail hub and the MX points here on purpose, the FAQ's pattern is a manualroute router before the DNS router, so Exim does not follow the MX back to itself.

Save the address test and the MX query before you edit anything. Each answer goes to its own file:

exim -bt <address> > bt-before.txt
dig <domain> MX > mx-before.txt

Change the MX in the zone

Risk: the next step changes the MX record of the domain in its DNS zone. A new MX sends the domain's mail to the host you name, for every sender. allow_mx_to_ip tells Exim to honour an MX that points at an address, but the FAQ's position is that those records are misconfigured, so prefer a hostname.

If you control the zone, replace an MX that points at an IP address, or at a name with no address records, with a hostname that resolves. Query that name from the Exim host before you rely on it.

To undo it: put the MX records that mx-before.txt shows back in the zone. If that file shows no MX record, delete only the MX record you added.

Change the routers

Save the router configuration first. Print the name of the runtime configuration file, then copy it:

exim -bP config_file
cp -a <config-file> <config-file>.before

Risk: the next step edits the Exim runtime configuration file. A router change can accept mail this machine should still relay, or bounce mail it should accept.

Open the file named by exim -bP config_file in your text editor. In the routers section, put a router that accepts the domain, such as the manualroute pattern above, ahead of the dnslookup router, or correct the domains setting of the router that should accept it. Do not add a second MX to hide a domain that a local router should accept. Save the file, and run exim -bt <address> again.

To undo it: copy the saved file back with cp -a <config-file>.before <config-file>.

Example (illustrative): exim -bt sam@example.net reports that all relevant MX records point to non-existent hosts. The MX target is the address 203.0.113.50 written as a name. The zone owner replaces it with mx.example.net and gives that name an A record of 203.0.113.50.

Confirm the fix

  1. exim -bt for the same address is accepted by a router, and the return code is 0.
  2. dig shows MX hostnames, and each hostname you expect to use has an address record.
  3. A real message to that address is delivered, or it defers with a retry line rather than bouncing as unrouteable.

What to watch afterwards

  • cannot_route_message changes the bounce text only. It does not make a router accept the address.
  • An MX pointed at this host comes back as "lowest numbered MX record points to local host". FAQ Q0301 gives three remedies: correct the domains settings of the routers, put a manualroute router before the DNS router for a hubbed domain, or get the DNS mended.

Risks and limits

  • The FAQ is the 4.66 HTML for Exim 4.43 and later. Its section 3 page shows no date, and the FAQ.html page shows "Last update: 14-October-2004". The current dnslookup chapter lists the same decline reasons in shorter words.
  • The options page says "Unrouteable address". Chapter 3 says "unrouteable address". They are the same default.
  • -bt skips routers with no_address_test, and it does not reproduce a router that depends on message content.

Sources