How do I block non-local domains from sending local mail through postfix?

0

I have postfix running under Alpine docker. If I start it up like so:

docker run --name local -it -p 2500:25 alpine sh
/ # apk update && apk add postfix
/ # newaliases
/ # mkdir /var/mail
/ # postfix start

Then from my host box I do:

$ telnet localhost 2500
EHLO whatever
MAIL FROM: whatever
RCPT TO: root
DATA
From: whatever
To: root
Subject: I'm not really on your server

And that's a problem!

.

It works and sends an email to root on the docker container. Boo. I don't want this at all. I would like for only localhost to be able to send messages sans domain (or on behalf of $mydomain).

Is it possible to do this with postfix, and if so, how?

Wayne Werner

Posted 2016-06-03T15:38:09.860

Reputation: 1 501

by default postfix allows relay via 127.0.0.0/8, do you want to disable that? – hkdtam – 2016-06-07T03:51:56.640

@hkdtam you mean localhost being able to relay email from wherever (presumably just localhost)? Nah, I'm not worried about that, I just don't want Random Joe on the internet to say that they're sending email from inside my house – Wayne Werner – 2016-06-07T16:20:01.783

as far as I can see your telnet test behaviour is normal (for a stock postfix on most distributions), if you want to apply more rigorous sender checks (there are plethora), just migrate your question to ServerFault and you should get more valuable results – hkdtam – 2016-06-08T04:39:24.333

No answers