Exim sending messages with ip assigned to other users

jkirker

Verified User
Joined
Nov 22, 2012
Messages
100
Thank you Alex for getting us so close to a request/suggestion/solution that's nearly 4 years in the making! Awesome.

So I guess the last piece of the puzzle is to automate the updating of the exim.conf file and the reloading/restarting of exim.conf

I don't know how to do this but I'm guessing it'd be done with perl or python. We might find the line # in the file that begins with local_interfaces = 127.0.0.1 and then rewrite it including the list of all available IP's on the machine.

###START ADDED###
disable_ipv6
local_interfaces = 127.0.0.1 : 211.82.195.29 : 211.82.195.118 : 211.82.195.119 : 211.82.195.120
smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/virtual/smtp_active_hostnames}{$value}}
smtp_banner = "$smtp_active_hostname ESMTP $tod_full"
###END ADDED###

Thoughts?

And Alex, please PM me with your paypal so that I can send you a small donation if you are interested. I really appreciate your efforts.

John
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,800
Location
A Coruña, Spain
Code:
sed -i 'smtp_banner = /d' /etc/exim.conf
sed -i 'smtp_active_hostname = /d' /etc/exim.conf
sed -i 'local_interfaces = /d' /etc/exim.conf
sed -i 'disable_ipv6/d' /etc/exim.conf
echo -e 'smtp_banner = "$smtp_active_hostname ESMTP $tod_full"\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf
echo -e 'smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/virtual/smtp_active_hostnames}{$value}}"\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf
echo -e 'local_interfaces = 127.0.0.1 : 211.82.195.29 : 211.82.195.118 : 211.82.195.119 : 211.82.195.120"\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf
echo -e 'disable_ipv6"\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf

This will add the lines at the top of the file (deleting them if already exist, so, will create them everytime those new lines)

For the IP list you can add those lines to last Alex's script and use the $IP variable.

I have no time now for integrate them, but i suppose that on eache discovered IP ti must be added in a new variable,

ex:
IPSPACED="$IP : "
IPS="$IPS$IPSPACED"

so the first time will be empty and get filled every new IP, and use $IPS in local_interface.

examples

local_interfaces = $IPS
or
local_interfaces = 127.0.0.1 : $IPS (if 127.0.0.1 is not discovered by Alex's script)

Regards
 

jkirker

Verified User
Joined
Nov 22, 2012
Messages
100
Ha... I tried the above and failed MISERABLY! Anyone available to put this together? This would put a bow on the whole thing. Then who knows, maybe it could be added into a CustomBuild at some future time. ;)

Big THANK YOU's to everyone who has contributed.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,252
Location
GMT +7.00
Thank you Alex for getting us so close to a request/suggestion/solution that's nearly 4 years in the making! Awesome.

So I guess the last piece of the puzzle is to automate the updating of the exim.conf file and the reloading/restarting of exim.conf

John

Hello John,

Please let me a couple of days, and I'll suggest my sollution for it.
 

interfasys

Verified User
Joined
Oct 31, 2003
Messages
2,099
Location
Switzerland
A couple of suggestions
  • Naming: It might be worth using something generic for files. We use domainips and reverse_domainips, but anything which describes the content rather than the use might be more useful in the long run
  • IPV6: Make the scripts IPv6 compatible or you'll end up with broken IP databases
  • Deprecated variables: $interface_address has been replaced by $received_ip_address when receiving emails in order to avoid confusion. DOC
  • iplsearch: Exim comes with various lookup tools. One of them is iplsearch which is designed specifically for IPs, including masks. DOC
  • Defaults: By reading the Exim condition which determines the active hostname, it seems to me like there is no default value to use as a fallback, which means that Exim will fail to receive emails if it can't determine the hostname to use. I could be wrong though


Examples:
Receiving
Code:
smtp_active_hostname = ${lookup{$received_ip_address}iplsearch{/etc/virtual/domainips}{$value}{$primary_hostname}}

Sending
Code:
interface = <; ${lookup{$sender_address_domain}lsearch{/etc/virtual/domainips_reverse} {$value}{$interface_address}}
helo_data can use the same code used for smtp_active_hostname, without having to create additional symlinks

Also, it's possible to avoid having to create any files if using DNS lookups, but that slows down processing.
 

duntuk

Verified User
Joined
Jan 23, 2007
Messages
50
A couple of suggestions
  • Deprecated variables: $interface_address has been replaced by $received_ip_address when receiving emails in order to avoid confusion. DOC

Sending
Code:
interface = <; ${lookup{$sender_address_domain}lsearch{/etc/virtual/domainips_reverse} {$value}{$interface_address}}
helo_data can use the same code used for smtp_active_hostname, without having to create additional symlinks

Also, it's possible to avoid having to create any files if using DNS lookups, but that slows down processing.

If $interface_address is deprecated, then shouldn't the above example be this:

Code:
interface = <; ${lookup{$sender_address_domain}lsearch{/etc/virtual/domainips_reverse} {$value}{$received_ip_address}}
 

duntuk

Verified User
Joined
Jan 23, 2007
Messages
50
Code:
echo -e 'local_interfaces = 127.0.0.1 : 211.82.195.29 : 211.82.195.118 : 211.82.195.119 : 211.82.195.120"\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf

That puts quotation marks at the end of the IP list", which invalidates the format. Should be:


Code:
echo -e 'local_interfaces = 127.0.0.1 : 211.82.195.29 : 211.82.195.118 : 211.82.195.119 : 211.82.195.120\n'"$(cat /etc/exim.conf)"'' > /etc/exim.conf
 
Top