Different IP for Email

Discussion in 'Installation/Configuration' started by dayjahone, Jul 14, 2015.

  1. dayjahone

    dayjahone Member

    I want to put one domain on a separate IP address for email. When I create an email box, I don't see any place to enter an IP. How is this done?
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no easy way to achieve this as postfix does not has such a setting. You can e.g. setup a virtual machine with a separate ispconfig installation or you try to add listeners for each IP separately in postfix master.cf instead of the global port 25 listener, but this will only affect incoming email and not outgoing.
  3. dayjahone

    dayjahone Member

    Thanks, Till. How can I change the IP address for mail only--on the whole server? Or is this a bad idea? I've been using an IP address for mail for a long time, and I'm wondering if it's time to change.
  4. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Postfix does support this, we have a single server (debian wheezy, non-ispconfig) using separate ip addrs for a couple domains (incoming and outgoing).

    The outgoing piece uses sender_dependent_default_transport_maps to select the default transport according to the sender address, eg. set this in main.cf
    sender_dependent_default_transport_maps = texthash:/etc/postfix/sender_dependent_default_transport_maps
    then create /etc/postfix/sender_dependent_default_transport_maps with:
    @dom1.com  dom1_smtp
    @dom2.com  dom2_smtp
    Then you create dom1_smtp and dom2_smtp transports that specify a different smtp_bind_address option, eg. in master.cf:
    dom1_smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=x.x.x.x
    dom2_smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=y.y.y.y
    The incoming pieces are handled similarly, ie. multiple transports created to listen on each address and set a few options differently.

    For another option, I believe you can accomplish the same thing with postfix instances as well, but I don't have a working example offhand.
    till likes this.
  5. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    One other thing that might be useful if someone were to incorporate such a config into ispconfig, we actually set variables with the bind IP addresses and use those in the transport definition. Eg. in main.cf:
    dom1_smtp_bind_address = x.x.x.x
    dom2_smtp_bind_address = y.y.y.y
    And in master.cf:
    dom1_smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=$dom1_smtp_bind_address
    dom2_smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=$dom2_smtp_bind_address
    You can then use postconf -e to set/change the ip address, rather than parsing master.cf (I don't know how how ispconfig handles that, it may or may not be easier).

Share This Page