Phil,
Thanks for the tips!
I do know (by trial and error), that if we do a DNS quesry for the MX, and
the first MX fails (because the IP returned cant be assigned), that it will
try the second, then third.
I will have to test the examples you sent to see if it will try the MX, then
the A. If the A record also fails, is there a way to set a deault IP with
the syntax you used?
-Grant
----- Original Message -----
From: "Phil Pennock" <exim-users@???>
To: "Grant Peel" <gpeel@???>
Cc: <exim-users@???>
Sent: Tuesday, October 06, 2009 8:50 PM
Subject: Re: [exim] Outgoing Interface
> On 2009-10-06 at 09:58 -0400, Grant Peel wrote:
>> Hi all,
>>
>> I would like to set the outgoing interface to the IP address assigned to
>> the user's domian.
>>
>> The problem I am encountering is that not all domains have thier MX set
>> to an IP on our server (because some domains are using a mail filtering
>> server that relays the message to our server after filtering).
>>
>> Is there a way to rewrite the transport's 'interface' lines below, so it
>> will attempt to use the MX, then the A record, then a default IP (the
>> servers main IP) in that order?
>
> I believe so.
>
> Note that a dnsdb mxh lookup will return multiple hosts and you're not
> setting a list separator, so that would also fail if sending with a
> sender address in a domain with multiple MX records.
>
> Also, the interface is supposed to be specified as a list of IP
> addresses.
>
> How about IPv6? Heck, it's easier to have IP-per-customer with IPv6.
>
> [Beware: long lines below, 80-column viewers may wrap or need scroll]
>
> IPv4-only:
> ${lookup dnsdb{>; a= <; ${lookup dnsdb{>; mxh=$sender_address_domain}} ;
> $sender_address_domain }}
>
> This says to do a lookup, using semi-colon as list separator for output,
> of the A records given as a semi-colon separated list; we then use MXH
> pseudo-type items to get the MX hostnames, results separated by
> semi-colon, and then add the domain itself on at the end, all used as
> input.
>
> IPv6/IPv4:
> ${lookup dnsdb{>; aaaa= <; ${lookup dnsdb{>; mxh=$sender_address_domain}}
> ; $sender_address_domain }} ; \
> ${lookup dnsdb{>; a= <; ${lookup dnsdb{>; mxh=$sender_address_domain}} ;
> $sender_address_domain }}
>
> Note the marked similarity there.
>
> Now, I forget whether or not the interface directive ignores IPs not
> locally bound or whether or not that results in an error. Skimming the
> source, it looks like you need to filter this. The @[] list includes
> all the IP addresses of the host that Exim is running on. We can use
> that to filter.
>
> ${filter{<string>}{<condition>}}
>
> Conveniently, filter reuses the list separator for the input list when
> generating the output list.
>
> So:
>
> ${filter{<; ${lookup dnsdb{>; aaaa= <; ${lookup dnsdb{>;
> mxh=$sender_address_domain}} ; $sender_address_domain }} ; \
> ${lookup dnsdb{>; a= <; ${lookup dnsdb{>;
> mxh=$sender_address_domain}} ; $sender_address_domain }}}\
> {match_ip{$item}{@[]}}}
>
> Finally, remember to tell interface of the list separator and the
> default IPs:
>
> interface = <; $STUFF_FROM_ABOVE ; @[]
>
>> # interface = ${lookup dnsdb{a=${lookup
>> dnsdb{mxh=$sender_address_domain}}}}
>
> Lather, rinse, repeat.
>
> Around about now, I wish Exim had user-defined functions written in
> Exim's configuration language. ;) Well, you can always write it in
> Perl or C and use the ${perl...} or ${dlfunc...} expansions.
>
> -Phil
>
> --
> ## List details at http://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>