Postfix + multiple relayhosts

Discussion in 'Installation/Configuration' started by warlock, Jun 1, 2010.

  1. warlock

    warlock Member

    Hi Guys,

    How do I configure postfix to deliver to multiple smtp relay hosts.
    We have 2 internet connection on a WAN bonder, if 1 line goes down we'd like post fix to deliver to a secondary smtp relay host.

    I have tried this
    relayhost = smtp1.box.com and smtp2.box.xom

    Code:
    postfix: fatal: relayhost parameter setting must not contain multiple values: smtp.mweb.net smtp.vbmail.co.za
    Is there an option to alternate for load balancing or at least for fail-over

    Thanks
    Guys
     
  2. yui72o

    yui72o New Member

    You should check this tutorial :
    http://souptonuts.sourceforge.net/postfix_tutorial.html
    At 4.2 they configure /etc/postfix/main.cf
    and at 4.5 (most usefull for you) is the configuration of multiple relays
    Please note that I think it is not at all for any load-balancing but multiple relays for local mail (Don't think you can ever do that with postfix ...)

    I hope this will help
     
  3. XoCine

    XoCine New Member

    Maybe that question is ooooooooold but have some nice solution :)

    Well warlock, in searching of solution I did some googling but did not found solution sooo I turned off Google and enable a Brain++ :->

    What we want? That Postfix connect to one of FEW hosts (relayhosts).

    Welll, lets play with DNS :)

    In example do domain mysweetdomain.com lets make some A lines:

    mxr IN A 192.168.1.121
    mxr IN A 192.168.1.131
    mxr IN A 192.168.1.141
    mxr IN A 192.168.1.151
    mxr IN A 192.168.1.161


    Lets flush bind and what we have? Nice :)

    [root@anubis postfix]# host mxr.mysweetdomain.com
    mxr.mysweetdomain.com has address 194.177.4.121
    mxr.mysweetdomain.com has address 194.177.4.131
    mxr.mysweetdomain.com has address 194.177.4.161
    mxr.mysweetdomain.com has address 194.177.4.141
    mxr.mysweetdomain.com has address 194.177.4.151

    Standard roundrobin rulez :-D

    Then only that little line in postfix/main.cf

    relayhost = mxr.mysweetdomain.com

    and Postfix relays with every of these ips in roundrobin style :)

    Maybe it does not work as failover but better have 3/5 relays working then none :) 60% delivered mails at once, rest waits for some time

    Simple and nice :) Hace fun :)
     
    Last edited: Jul 20, 2011
  4. solteranis

    solteranis New Member

    I know this is a very old question, but another solution is to utilize HAProxy. Listen on port 25, relay to yourself (I used port 26) use HAProxy to load balance this to your backend relay servers.

    Another perk of this solution is HAProxy can automatically detect if a relay host goes down, and remove it from the list.
     

Share This Page