[exim] Routing based on *recipient* IP address

Top Page
Delete this message
Reply to this message
Author: Gandalf Corvotempesta
Date:  
To: exim-users
Subject: [exim] Routing based on *recipient* IP address
Hi guys

TL;DR: how can i route, to a specific smarthost, all email based on
the *recipient* mx IP address ?

Long version:

I have a mail server hosted on Google Cloud that can't reach some
"restricted" countries, like Cuba, Iran, Syria and so on.

A customer of us, has a department located in Iran and is unable to
communicate to them, so i've started an AWS instance (that is able to
reach the remote iran server) and i would like to route, from my GCE
instance all email that should be routed to an iran IP address (i have
a list, downloaded from ipdeny.com), to my AWS instance.

I can check for the remote MX in the transport, but:
1. i'm getting a list of multiple hosts
2. i need to convert one (or more) of them to IP addresses
3. i need to check if at least one of these IP is inside a file
(automatically updated from ipdeny.com)

I don't know how to start.
Any help, or any better solution ? Checking the recipient TLD would be
much easier but not all recipients ends in ".in"

Currently, as workaround, i've set the AWS as fallback_host, because
when an email is routed to Iran, goes in timeout and then routed to
the fallback_host, but this is no good because is routing throuhg AWS
all emails that are triggering a timeout but I need to route *only*
emails to some ip addresses

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/