Select sending ip

gdp01

Verified User
Joined
Oct 7, 2019
Messages
23
Hello, I am trying to make exim select the sending IP, I have the following configuration in remote_smtp

interface = <; ${if exists{/etc/virtual/domainips}{${lookup{$sender_address_domain}lsearch*{/etc/virtual/domainips}}}{${perl{randinet}}}}}

I have in the domainips file a domain with a sending IP. What I want to do is that if it does not find the domain in that file, use the random ips sending file. Is this configuration correct? Would there be another way to do it? Thank you
 

wila

Verified User
Joined
Dec 15, 2017
Messages
58
Hi,

You shouldn't need to play with configuration files for that part.
Most likely you want to edit
/etc/virtual/domainips
and
/etc/virtual/helo_data

See also: https://www.directadmin.com/features.php?id=1692

Much easier than tweaking those config files.

Edit: Sigh.. reading is an art.
Never mind, please disregard, seems you know about this already.
 

gdp01

Verified User
Joined
Oct 7, 2019
Messages
23
Hello, yes, I have made that configuration, but what I want exactly is if the domain is not in the /etc/virtual/domainips file, send it through a pool of IPS addresses.

If used *:X.X.X.X it would only be sent by a single IP and the configuration that I want is not like that.

Any ideas?

thanks
 

wila

Verified User
Joined
Dec 15, 2017
Messages
58
Sadly I'm not that intimate with the config style that exim uses.
Yes, I've used it in the past, but was never comfortable touching it, so I'm very happy that I can stay away from that nowadays.

If I had your requirement then I would probably setup a cron job that runs every 5 minutes or so and only changes the *:X.X.X.X line in /etc/virtual/domainips.
A small script (sed/awk?) could take care of that.
Of course... that would be a bit of a hack.
 

gdp01

Verified User
Joined
Oct 7, 2019
Messages
23
Yes, the exim configuration is a bit special. Finally I have used your method @wila, I have made a script that changes the general IP every 2 minutes so that it rotates, leaving a dedicated IP for the domain I want. I'll leave it here, I'm not an expert in bash but it does its job :D

Code:
#!/bin/sh
arr[0]="*:X.X.X.X"
arr[1]="*:X.X.X.X"
arr[2]="*:X.X.X.X"
arr[3]="*:X.X.X.X"
arr[4]="*:X.X.X.X"

rand=$[$RANDOM % ${#arr[@]}]

sed -i "/^*:/s/.*/${arr[$rand]}/" /etc/virtual/domainips
Thanks
 

wila

Verified User
Joined
Dec 15, 2017
Messages
58
Seems you are fine with bash.
Thanks for sharing how you managed to get it to work.
 
Top