Postfix as a local relay

This can be used for situations where you have an internet facing machine (web server) and back-end machines (application server, database server, etc.).

In our examples, we’ll assume the following:
Internet facing web server IP is 192.168.1.2
Back-end database IP is 192.168.1.3
Back-end database IP is 192.168.1.4

On your Internet facing machine, edit /etc/postfix/main.cf and add your back-end server IP’s to your mynetworks section or add a new one. For example:
mynetworks = 127.0.0.0/8, 192.168.1.3, 192.168.1.4

On each back-end machine, add the following to /etc/postfix/main.cf:
relayhost = 192.168.1.2

Try sending an email using mailx. You should see the following in your mail log on each back-end server (Notice the relay line):
ADA08211D5: to=, relay=192.168.1.2[192.168.1.2]:25, delay=0.18, delays=0.05/0.02/0.09/0.01, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as CF54E21217)

This entry was posted in Uncategorized. Bookmark the permalink.

Comments are closed.