Linode Forum
https://forum.linode.com/

Setup relay only for specific domain
https://forum.linode.com/viewtopic.php?f=11&t=11354
Page 1 of 1

Author:  alastc [ Thu Oct 09, 2014 4:53 pm ]
Post subject:  Setup relay only for specific domain

Hi,

I have two linodes, one for my personal use (domain1.com) the does web and email for me and a few friends, and one for an organization I help out (domain2.com). I've followed the postfix/dovecot/mysql tutorial (which was very good), my setup is exactly that on domain1.com but with a commercially-signed certificate. Domain2.com only receives email for domain2 (and forwards it to individual email addresses elsewhere), and only sends server-side email like forgotten password links from web-apps.

I would like avoid user-email on domain 2, which means that to send as domain2.com (with reverse DNS, SPF etc) I'd like to relay from domain1.com to domain2.com, but only when sending as me@domain2.com. Everything else should be sending as normal, with DNS lookup/routing etc.

I did a little diagram to help:
Image

I'm struggling to work out what settings I need on each server, can anyone help, or provide keywords to assist my googling? "relay" isn't really working very well!

Also, if it's easier, it would be ok to use the username as the switch for whether to use domain2.com for SMTP, rather than sender address.

Author:  alastc [ Thu Oct 09, 2014 7:24 pm ]
Post subject:  Re: Setup relay only for specific domain

I think I've worked this out, in the mail.cf for postfix on domain1 add:
Code:
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhost_maps


The sender_dependent_relayhost_maps file includes lines such as:
Code:
me@domain2.com     [domain2.com]:25


You then hash that file:
Code:
#postmap sender_dependent_relayhost_maps

And reload postfix.

Then on domain2.com's main.cf add the IP address of domain1.com to the mynetworks setting, e.g.
Code:
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, 123.123.123.123


And reload postfix.

Does that seem right? It works, have I opened up any issues?

Author:  Vance [ Sun Oct 12, 2014 12:38 pm ]
Post subject:  Re: Setup relay only for specific domain

The concern that comes to mind is that because domain2.com trusts mail from domain1.com, whether someone can trick domain1.com into routing spam through domain2.com.

I'm not deeply familiar with this corner of Postfix but it looks like this shouldn't be a problem unless you have changed allow_untrusted_routing to yes. Old standards (and even older practice) allowed the sender to specify the route a message would take through multiple mailservers. This is now deprecated, but these things have a way of hanging on. It seems like the allow_untrusted_routing setting in Postfix will prevent this.

Author:  alastc [ Sun Oct 12, 2014 3:35 pm ]
Post subject:  Re: Setup relay only for specific domain

The allow_untrusted_routing defaults to no, and it doesn't feature in my main.cf.

I think the relevant bit for who can send is:

Code:
smtpd_recipient_restrictions =
        permit_sasl_authenticated,
        permit_mynetworks,
        reject_unauth_destination


Thanks for thinking about it.

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/