Re: [exim] Exim as transparent Rewrite Gateway

Top Page
Delete this message
Reply to this message
Author: Viktor Dukhovni
Date:  
To: Exim-users
Subject: Re: [exim] Exim as transparent Rewrite Gateway

> On Apr 24, 2017, at 6:14 PM, Heiko Schlittermann via Exim-users <exim-users@???> wrote:
>
> Dennis Weber <dennis.weber@???> (Sa 22 Apr 2017 23:01:26 CEST):
>> Hi Community,
>>
>> I am currently working on a project for a transparent Rewrite Gateway which shall mask two independent Exchange Organizations behind a third domain. First I tried to solve this task by using a Postfix server, but Postfix was not able to rewrite the "From" and "To" the way the gateway is a completely independent black box, because incoming mail got a rewritten "To" field, but the mail was still delivered with the new domain suffix of which the internal mail server don't know anything from.
>
> Header rewriting doesn't imply any impact to the routing, as the
> headers are not relevant for SMTP mail routing. I'm not sure, if you
> need any other component of Postfix to change the mailrouting, not only
> the headers. I'm not a Postfix expert at all…


I explained to the OP how to solve this with Postfix (which can handle
this task without much pain) but it seems he did not understand or did
not see my reply.

Perhaps he will find Exim's interface more intuitive, but first he'll
need to understand the distinction between the message headers and
envelope. My reply attached below, in case the OP missed it on the
Postfix-users list.

-- 
    Viktor.



> On Apr 23, 2017, at 7:12 AM, Dennis Weber <dennis.weber@???> wrote:
>
> I am currently working on a project for a rewriting gateway with postfix, which shall mask two independent internal domains behind a third external DNS name. In general it should accept mails from @internal1.com and @internal2.com as a Smarthost, rewrite the addresses with a new @newcorp.com domain and send it to the public network. Besides the outgoing rewrite it also needs to rewrite incoming mail to both internal domains and transport them to the right Exchange organizations.


See http://www.postfix.org/SOHO_README.html#fantasy

> I managed to rewrite the outgoing messages with the “generic_maps” and a simple filetable


Good, that's the right thing to do outbound, but you should configure the
"smtp_generic_maps" parameter separately for inbound and inbound mail:

    main.cf:
        indexed = ${default_database_type}:${config_directory}/
        relay_generic_maps =
        smtp_generic_maps = ${indexed}generic
        transport_maps = ${indexed}transport
        virtual_alias_maps = ${indexed}virtual
        virtual_alias_domains = example.com


    master.cf:
        ...
        smtp unix ... smtp
        relay unix ... smtp
            -o smtp_generic_maps=$relay_generic_maps
        ...


    transport:
        # Inbound mail uses the "relay" transport which
        # avoids the outbound "generic" rewrite.
        # Add optional nexthop gateways as appropriate
        internal1.example    relay
        internal2.example    relay


    virtual:
        # Map external *envelope recipient* addrs to internal
        user1@???    user1@???
        user2@???    user2@???
        ...


    generic:
        # Map internal addrs to external in envelope and headers
        user1@???    user1@???
        user2@??? user2@???    

    
>     • Messages rewritten with “header_checks” cannot be delivered too, because of the same reason mentioned above


NEVER EVER ATTEMPT OR EVEN THINK ABOUT using header checks for address
rewriting.

-- 
    Viktor.