[Exim] Re: Routing to first MX only

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: edouard.boucher
Fecha:  
A: exim-users
Asunto: [Exim] Re: Routing to first MX only
hi,


>>>>I am trying to set up a router which act like dnslookup,
>>>>but discard all the MX record that are not primary, and fail if no MX record.
>>>>is the easiest way to set this a hack in src/routers/dnslookup.c ?


>>>I hope you don't want to apply this rule to all outgoing mail. Some
>>>people use to have reasons for having multiple (e.g. IPv6 only primary
>>>MX) or no (reduce number of DNS RRs in conformance with RFC821) MX.


>> I want to use this kind of routing only for a very specific case.
>> it is not my default router !
>>>Otherwise have a look at dnsdb lookups and the manualroute router.
>> i tryed but a dnsdb gives a list of all the mx,
>> and i have no idea of how to extract only the lowest.
>run the result through an external command, or use some fancy recursive
>calling of the router and a tricky usage of address_data


>I don't know if this set of routers will work, i just wrote them down,
>without testing, whatever, but maybe you can see what i want to do, and
>how it could be done.


># First lookup the MX records and save it in address_data
>lookup_mx:
> driver = redirect
> domains = +backup_domains
> address_data = ${lookup dnsdb {MX=$domain}}
> data = $local_part@$domain
> redirect_router = loop_mx


># Loop until we have NO newline left in our address_data
># in every loop we compare the first two MX values to each
># other, and strip the one with the bigger value
>loop_mx:
>   driver = redirect
>   domains = +backup_domains
>   condition = ${if match {$address_data}{\\n}{1}}
>   address_data = ${if match {$address_data} \
>        {\N(\d+)\s+([^\n]+)\n(\d+)\s+([^\n]+)(.*)\N} \
>        {${if < {$1}{$3} {$1 $2$5}\
>                         {$3 $4$5}}}\
>   }
>   data = $local_part@$domain
>   redirect_router = loop_mx


># this finaly routes the domain, with the host in $address_data
>route_domain:
> driver = manualroute
> domains = +backup_domains
> condition = ${if eq {}{$address_data}{1}{0}}
> route_data = ${extract {2}{ }{$address_data}}




>Any comments?


Thanks,
that's a pretty nice router config !

I tryed to test it with exim -d+route -bt mail@address
and i get unroutable addr,
apparently, it goes in the loop_mx only once,
i suppose it it because (quote from the exim spec):
redirect_router has no effect if the router in which it is set does not generate
new addresses
but i am not sure.

what do you think ?


Edouard