Mailing List Archive

How to choose the outgoing IPs for an E-Mail
Hi, List!

I'd like to have a file such this:

lucabert.de: ips=<; 84.200.210.163 ; 2001:1608:10:24:1::1
other.domain.tld: ips=<; 84.200.210.164 ; 2001:1608:10:24:300::1
v4.domain.tld: ips=84.200.210.165

and having the given IPs be used to send E-Mails from these domains...

I think, I have to use this file in the transports, and I tried this:

remote_smtp:
driver = smtp
helo_data = $smtp_active_hostname
interface =
${extract{ips}{${lookup{$sender_address_domain}lsearch{/etc/exim/mailouts}{<;
84.200.210.163 ; 2001:1608:10:24:1::1}}}}

Unfortunately, it does not work...
It will always used an IP I didn't give in any configuration...

Could someone help me?
Of course, I need to have a default, if the $sender_address_domain does not
have an entry in /etc/exim/mailouts.

Thanks for any help!
Luca Bertoncello
(lucabert@lucabert.de)

--
## List details at https://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/
Re: How to choose the outgoing IPs for an E-Mail [ In reply to ]
On 2012-04-18 19:53, Luca Bertoncello wrote:
> remote_smtp:
> driver = smtp
> helo_data = $smtp_active_hostname
> interface =
> ${extract{ips}{${lookup{$sender_address_domain}lsearch{/etc/exim/mailouts}{<;
> 84.200.210.163 ; 2001:1608:10:24:1::1}}}}
>
> Unfortunately, it does not work...
> It will always used an IP I didn't give in any configuration...

First, is it using that transport? What do the "T=" portions of your
delivery lines in the logs say?
--
Jeremy


--
## List details at https://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/
Re: How to choose the outgoing IPs for an E-Mail [ In reply to ]
Jeremy Harris <jgh@wizmail.org> schrieb:

> On 2012-04-18 19:53, Luca Bertoncello wrote:
> > remote_smtp:
> > driver = smtp
> > helo_data = $smtp_active_hostname
> > interface =
> > ${extract{ips}{${lookup{$sender_address_domain}lsearch{/etc/exim/mailouts}{<;
> > 84.200.210.163 ; 2001:1608:10:24:1::1}}}}
> >
> > Unfortunately, it does not work...
> > It will always used an IP I didn't give in any configuration...
>
> First, is it using that transport? What do the "T=" portions of your
> delivery lines in the logs say?

Hi, Jeremy!

I use an smtp-transport...

I tried this, now:

interface =
${lookup{$sender_address_domain}lsearch*{/etc/exim/mailouts}{$value}{}}

Using a file like this:

lucabert.com: <; 84.200.210.163 ;
*: <; 84.200.210.163 ; 2001:1608:10:24:1::1

Now the problem is, that, if I try to send an E-Mail from lucabert.com, Exim
tries to use an IPv6, even if I just gived an IPv4...

What am I doing wrong?

Thanks
Luca Bertoncello
(lucabert@lucabert.de)

--
## List details at https://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/
Re: How to choose the outgoing IPs for an E-Mail [ In reply to ]
On 2012-04-18 at 21:25 +0200, Luca Bertoncello wrote:
> Now the problem is, that, if I try to send an E-Mail from lucabert.com, Exim
> tries to use an IPv6, even if I just gived an IPv4...

Exim looks up the addresses to try, and filters the available source
address to be one for that family. If you only provide an IPv4 address,
then a connection to an IPv6 endpoint will not have a forced chosen IPv6
source address.

You can disable IPv6 in the configuration, with "disable_ipv6" in the
main configuration section. You can also set "dns_ipv4_lookup" there,
to point to domains that IPv6 lookups should be avoided for, if you know
of broken servers.

On a Router, you can use "ignore_target_hosts" to disable either IPv4 or
IPv6, by specifying the relevant "any" address as the value.

So you might use a forany/forall check against the result of the
existing config file, combined with isip4/isip6, to decide if you have
chosen an appropriate source address for that destination, and then set
ignore_target_hosts appropriately. It will be a little convoluted to
read. Or you might have the system which generates the existing lookup
file also generate a different lookup file. Or you might duplicate the
Router, make the first one IPv4-only with ignore_target_hosts set to a
fixed string instead of a lookup but do the same forall/isip4 check,
this time in a "condition" rule.

-Phil

--
## List details at https://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/
Re: How to choose the outgoing IPs for an E-Mail [ In reply to ]
Phil Pennock <exim-users@spodhuis.org> schrieb:

Hi, Phil!

> Exim looks up the addresses to try, and filters the available source
> address to be one for that family. If you only provide an IPv4 address,
> then a connection to an IPv6 endpoint will not have a forced chosen IPv6
> source address.

That's right! I just forgot that... :(

> You can disable IPv6 in the configuration, with "disable_ipv6" in the
> main configuration section. You can also set "dns_ipv4_lookup" there,
> to point to domains that IPv6 lookups should be avoided for, if you know
> of broken servers.
>
> On a Router, you can use "ignore_target_hosts" to disable either IPv4 or
> IPv6, by specifying the relevant "any" address as the value.
>
> So you might use a forany/forall check against the result of the
> existing config file, combined with isip4/isip6, to decide if you have
> chosen an appropriate source address for that destination, and then set
> ignore_target_hosts appropriately. It will be a little convoluted to
> read. Or you might have the system which generates the existing lookup
> file also generate a different lookup file. Or you might duplicate the
> Router, make the first one IPv4-only with ignore_target_hosts set to a
> fixed string instead of a lookup but do the same forall/isip4 check,
> this time in a "condition" rule.

Yes, it will be very complicated...

I decided to do that:

My tranport:

remote_smtp:
driver = smtp
helo_data = $smtp_active_hostname
interface =
${lookup{$sender_address_domain}lsearch{/etc/exim/mailouts}{$value}{<;
DEFAULT_IPv4 ; DEFAULT_IPv6}}

My /etc/exim/mailouts uses this format:

domain.tld: <; 12.34.56.78 ; 2001:1234::1
ipv4.domain.tld: <; 12.34.56.78 ; ::2

If I try to send an E-Mail from any address @ipv4.domain.tld Exim tries first
to bind to ::2 and it cannot, then it tries using 12.34.56.78.
I get a warning in my exim_mainfile, but I think, this is acceptable...
I don't think, I will use too much the option to just use IPv4, even if it
can be possible to use IPv6... It was just if in the future, I want to have a
domain that only use IPv4...

Thanks again!
Luca Bertoncello
(lucabert@lucabert.de)

--
## List details at https://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/