Load balancing outgoing mail relay

Michael K. Smith - Adhost mksmith at adhost.com
Wed Jan 17 21:31:43 UTC 2007


> -----Original Message-----
> From: owner-freebsd-questions at freebsd.org [mailto:owner-freebsd-
> questions at freebsd.org] On Behalf Of freebsd
> Sent: Wednesday, January 17, 2007 2:34 AM
> To: FreeBSD Questions
> Subject: Load balancing outgoing mail relay
> Hi
>  I have a simple question but googling does not lead to a valid/usable
> answer.
> I need to load balance OUTGOING emails. I have serveral smart hosts. I
> need
> my internal SMTP server to send mail using ALL of the smart hosts
> together,
> making some kind of load balancing (no need for wheighted one).
> Someone pointed out to use a name for the smart host, and have DNS to
> resolve that name to the IP of all the relays (multiple A records) but
> this
> turned out in doing failover, not load balancing.
> Anyone has a *working* idea for solving this apparently simple
> Thanks

PF will definitely do what you want via its round-robin and redirect
features.  You would redirect all inbound traffic on port 25 to your
smart host group/table which would then load balance across all of your
servers.  In pf.conf, something like the following, with the
understanding that there are other things you may need to do first
before a pf config will work:

$int_if="em1"  # replace with the interface name from your machine
$ext_if="em0"  # replace with the interface name from your machine


table <smtp_roundrobin> persist { \
	$smart_host_01, \
	$smart_host_02, \
	$smart_host_03 \

rdr on $int_if proto tcp from $mail_server_01 to any port 25 ->
<smtp_roundrobin> round-robin 

The configuration can become more granular (complex) by including NAT
and ALTQ if you want to do rate-shaping.



More information about the freebsd-questions mailing list