Exim sending messages with ip assigned to other users

Great. Let me know. I know it'd be of value to me and the DA community.
 
PHP:
local_interfaces = 127.0.0.1 : a.a.a.a : b.b.b.b : c.c.c.c : d.d.d.d
Where did you find that line? What version of exim.conf, what line #? Or did you add it yourself? The variable doesn't appear to be in my copy of exim.conf.

Thanks.

Jeff
 
I added this to the top of my (i'm using your nobaloney) exim.conf file... :)

Here's a direct cut and past.

Should be able to put the IP's in an external generated file as well yes?

Code:
# CONFIGURATION STARTS HERE
###START ADDED###
disable_ipv6
local_interfaces = 127.0.0.1 : 216.82.195.25 : 216.82.195.60 : 216.82.195.63 : 216.82.195.64 : 216.82.195.68 : 216.82.195.69 : 216.82.195.77 : 216.82.195.79 : 216.82.195.80 : 216.82.195.81 : 216.82.195.82 : 216.82.195.83 : 216.82.195.84 : 216.82.195.85
smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/virtual/smtp_active_hostnames}{$value}}
smtp_banner = "$smtp_active_hostname ESMTP $tod_full"
###END ADDED###
 
Last edited:
Thanks, just found it in the documentation. Says it's a string list, so it probably can't be read from anexternal file.

Test it and see :).

Jeff
 
Thanks, just found it in the documentation. Says it's a string list, so it probably can't be read from anexternal file.

Test it and see :).

Jeff

I suppose another option would be to wrap the line/code with some delimiter and then use perl or something to replace what lives between the ears? Like updating a template. It's a little dangerous to update on the fly like that - but so long as there are some incremental backups, it should be doable.

I'm a hack coder at best these days since I've been hiring it out for the last 15 year. ;) So... That's why I'm offering to pay to have it done. Then, when it is done, everyone can have it.
 
For creating /etc/virtual/domainips you can use the following script of mine.

Code:
#!/bin/bash#
# by Alex S Grebenschikov ([email protected])
# v.0.1.2 2014-03-08
#


get_ip() {
    ip=`grep "^ip=" /usr/local/directadmin/data/users/$owner/domains/$domain.conf | cut -d\= -f2`
}


if [ -f "/etc/virtual/domainips" ]; then
    mv /etc/virtual/domainips /etc/virtual/domainips.bak`date +%Y%m%d`
fi;


touch /etc/virtual/domainips;


servername=`grep ^servername= /usr/local/directadmin/conf/directadmin.conf | cut -d\= -f2`


for domain in `cat /etc/virtual/domains | grep -v ^$servername$ | sort | uniq`;
do
    ip='';
    owner=`grep ^$domain: /etc/virtual/domainowners | cut -d\  -f2`


    if [ -f "/usr/local/directadmin/data/users/$owner/domains/$domain.conf" ]; then
        # REGULAR DOMAIN
        get_ip;
        echo "[D] Found domain $domain owned by $owner. IP=$ip";
        [ -z "$ip" ] || echo "$domain:$ip" >> /etc/virtual/domainips;
    else
        # POINTER
        pointer=$domain;
        if [ -d "/etc/virtual/$domain" ]; then
            domain=`ls -ld /etc/virtual/$domain | awk '{print $11}'`
        fi;
        get_ip;
        echo "[P] Found domain pointer $pointer to $domain owned by $owner. IP=$ip";
        [ -z "$ip" ] || echo "$pointer:$ip" >> /etc/virtual/domainips;
    fi;


done;


chmod 440 /etc/virtual/domainips;
chown mail:mail /etc/virtual/domainips;


exit;

You can run it in cron on any other specific action.

It add all domains/pointers/aliases into /etc/virtual/domainips file.
 
Last edited:
With other scripts the things are not that simple, but still not that difficult at the same time, and it's of course resolvable. Just need to know the logic. An user with a dedicated IP might have several domains on it. Of course for HELO data and hostnames we could select the primary domain from the account (selected in directadmin as the default one).
 
Of course for HELO data and hostnames we could select the primary domain from the account (selected in directadmin as the default one).

Thank you so much for sharing! This get's us 1/4 - 1/3 the way there. ;)

And yes, using the primary domain would allow the admin or user to use the tools which already exist to select which would be best for them.

Of course, there are also complexities when multiple ip's are assigned to a user but I think these situations are less common.

I'm going to try your script now. Thank you again. ;)

PS. I did find one bug/issue that I do not know how to fix. If there is an account that is suspended, it will create a row which contains only the :

ex:
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
:
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
domain.com : xxx.xxx.xxx.xxx
 
Last edited:
And yes, using the primary domain would allow the admin or user to use the tools which already exist to select which would be best for them.


And what about shared IPs? For some reasons there might be several shared IPs with more than one domain of more than one user there (resellers for example). What name should we choose for HELO and HOSTNAME? And how to choose?
 
And what about shared IPs? For some reasons there might be several shared IPs with more than one domain of more than one user there (resellers for example). What name should we choose for HELO and HOSTNAME? And how to choose?

The updated script worked perfectly...

Yes, for shared IP's I think the HOSTNAME would be most appropriate. You agree?
 
Anyone? Alex, I can't think of anything else that we might use, unless there was only one domain on the shared IP in which temporarily we might use that - but if you are doing things like I am and matching the PTR record to the hostname (or dedicated domain) I think you may as well just use the Hostname.
 
Mail from own IP-adres

Hi, I'm a newbe and I wonder if somebody can help me.

I have a VPS with 20 IP-adresses for a few clients. I want them to send email by there own ip-adres.

Client A: 149.xxx.129.xx1
Client B: 149.xxx.129.xx2
Client C: 149.xxx.129.xx3
Client D: 149.xxx.129.xx4
etc

I saw a few articles but I really don't know how to start. I'm working a few years with directadmin but I am new in ssh. Is there somebody who can help me step by step to do this?

Thanks a lot!

Grtz Albert
 
In the spirit of keeping momentum, and if nobody wants to contribute an opinion as to what to use for the default name if multiple shared IP's live on a saver; shall we just use HOSTNAME?

John
 
I'm not sure that it is a good idea, unless the hostname can be resolved to that IP among others. So hostname should resolve to multiple IPs.
 
Currently my hostnames both resolve and have associated PTR records as well.

In my doing all this manually, I am using the HOSTNAME for the shared IP.

Aren't we most concerned with using proper naming with DNS/A/PTR records and machine name and having everything set up properly?

Of course, multiple names will point to the IP, but the IP should realistically only have on name answering back.

Or am I incorrect?
 
I thought about this last night. What does Exim use by default if there are a number of domains which share a single IP? HOSTNAME?

Whatever Exim uses by default on a shared IP should be mimic'd with what is done here. @nobaloney, you are the Exim authority? Thoughts?
 
Exim uses hostname unless you reconfigure it. I'm not sure if you can set exim to use multiple domain-name/ip# pairs for outgoing email by configuration changes or not. I believe I've seen reference to it here on these forums within the last week but I'm not sure.

If you do figure it out you'll need to be careful:

While RFCs technically say mail should be accepted as long as rDNS resolves, whether or not it resolves to the same name's A record, many servers, in a (somewhat misguided) attempt to slow spam, won't accept email unless rDNS <->domain-name <-> DNS.

and...

If exim connects with a helo sender, then that domain name must have a working (monitored by a human) abuse address, and a working (also monitored by a human) postmaster address.

And don't forget that RFCs do not define what gets returned when/if you have multiple PTR records for one IP#, and so what BIND and other nameservers may return is undefined, unknown, and probably won't be what you expect, so don't do it.

Jeff
 
A script for creating /etc/virtual/smtp_active_hostnames.sh

A script for creating /etc/virtual/smtp_active_hostnames.sh
The file /etc/virtual/helo_data is a link to /etc/virtual/smtp_active_hostnames

Code:
#!/bin/bash
#
# by Alex S Grebenschikov ([email protected])
# v.0.1 2014-03-22
# Only IPv4 supported
#




save_to_file="/etc/virtual/smtp_active_hostnames";
servername=`grep ^servername= /usr/local/directadmin/conf/directadmin.conf | cut -d\= -f2`;


if [ -f "${save_to_file}" ]; then
    echo "Creating a backup copy of the file ${save_to_file}";
    mv ${save_to_file} ${save_to_file}.bak`date +%Y%m%d`;
fi;


touch ${save_to_file};


for IP in `cat /usr/local/directadmin/data/admin/ip.list | grep -v ^127.0.0.1$ | grep "\." | sort`;
do
{
    status='';
    owner='';
    hostname='';
    echo -n "[IP] Found ${IP}";
    if [ -f "/usr/local/directadmin/data/admin/ips/${IP}" ]; then
    {
        status=`grep ^status= /usr/local/directadmin/data/admin/ips/${IP} | cut -d\= -f2`;
        [ "${status}" != "owned" ] || owner=`grep ^value= /usr/local/directadmin/data/admin/ips/${IP} | cut -d\= -f2`;


        echo -n " with status=${status} ${owner}";
        hostname=${servername};


        if [ "${status}" == "owned" ]; then
        {
            homedir=`grep "^${owner}:" /etc/passwd | cut -d\: -f6`;
            if [ -d "${homedir}/public_html" ]; then
            {
                hostname="mail.`ls -dl ${homedir}/public_html | awk '{print $11}' | cut -d\/ -f3`";
            }
            fi;
        }
        fi;
        echo " hostname set to ${hostname}";


        echo "${IP}: ${hostname}" >> ${save_to_file};
    }
    fi;
}
done;


exit 0;
 
Back
Top