On a test server I have set up, I'm attempting to reject senders where
the sender domain has an MX record pointing to an internal (or
reserved) IP address. Reading the Exim documentation, this is what
I've come up with:
deny message = Sender domain ($sender_address_domain) has an MX record \
within reserved IP space.
condition = ${if \
forany \
{${lookup dnsdb{>: mxh=$sender_address_domain}}} \
{match_ip \
{${lookup dnsdb{a=$item}}} \
{iplsearch;/usr/local/etc/exim/reserved_ip_space} \
} \
{yes}{no}}
log_message = Sender domain ($sender_address_domain) has an MX record \
within reserved IP space.
/usr/local/etc/exim/reserved_ip_space has a list of IP address ranges
in CIDR format of all the internal (or reserved) IP space.
It is working as expected. I am just curious if there is an alternate
or reduced way of performing the same results.