LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-16-2015, 07:41 AM   #1
zohman
LQ Newbie
 
Registered: Sep 2015
Posts: 3

Rep: Reputation: Disabled
Question Postfix - securing relaying domains


Hi All,

i have setup Postfix with MailScanner/SA etc.

To allow relay from mail servers i was adding the remote static IPs
to "mynetworks" on postfix main.cf and for the mail shield (mx records from outside)
i added the remote domains to /etc/postfix/transport with the related fqdn of the
final destination. (of course i have security checks, custom ports and other stuff not for your concerns)

everything is working great and smooth,
i just try to understand if it's possible in postfix to bind the
sender domain to the IP is relaying from,

let me explain,
remote mail server ip: 1.1.1.1
sent from domain: @contoso.com

if the remote mail server send an email it goes to the relay server,
postfix check if the sending IP allow relay, and permit this IP to relay,
so far so good, but i want to tell postfix regardless of the allowing relay
to allow not just the remote IP but also the "MAIL FROM:" domain from the envelpoe.

the idea is, if it comes from server ip: 1.1.1.1 and from @contoso.com it will be Allow,
if it comes from server ip: 1.1.1.1 but from @fabrikam.com it will be deny,
i want to deny it at the smtp protocol level, im trying to prevent spambot or
open relay proxy if the remote site will get virus or any trojan.

Thank you in advance.

Last edited by zohman; 09-16-2015 at 07:43 AM.
 
Old 09-16-2015, 12:06 PM   #2
xspikx
LQ Newbie
 
Registered: Jun 2012
Location: Toronto
Posts: 5

Rep: Reputation: Disabled
You can try to create a "header_check" rule file.
In that file you can specify:

/^From: .*@fabrikam\.com/ DISCARD

This way any email coming from that domain would be discarded.


Quote:
Originally Posted by zohman View Post
Hi All,

i have setup Postfix with MailScanner/SA etc.

To allow relay from mail servers i was adding the remote static IPs
to "mynetworks" on postfix main.cf and for the mail shield (mx records from outside)
i added the remote domains to /etc/postfix/transport with the related fqdn of the
final destination. (of course i have security checks, custom ports and other stuff not for your concerns)

everything is working great and smooth,
i just try to understand if it's possible in postfix to bind the
sender domain to the IP is relaying from,

let me explain,
remote mail server ip: 1.1.1.1
sent from domain: @contoso.com

if the remote mail server send an email it goes to the relay server,
postfix check if the sending IP allow relay, and permit this IP to relay,
so far so good, but i want to tell postfix regardless of the allowing relay
to allow not just the remote IP but also the "MAIL FROM:" domain from the envelpoe.

the idea is, if it comes from server ip: 1.1.1.1 and from @contoso.com it will be Allow,
if it comes from server ip: 1.1.1.1 but from @fabrikam.com it will be deny,
i want to deny it at the smtp protocol level, im trying to prevent spambot or
open relay proxy if the remote site will get virus or any trojan.

Thank you in advance.
 
1 members found this post helpful.
Old 09-16-2015, 03:48 PM   #3
zohman
LQ Newbie
 
Registered: Sep 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by xspikx View Post
You can try to create a "header_check" rule file.
In that file you can specify:

/^From: .*@fabrikam\.com/ DISCARD

This way any email coming from that domain would be discarded.

Thanks for the answer,
but i dont see how it match my needs..
first, fabrikam.com is an example, it can be any domain other then the true originating domain (contoso.com for example).
and how exactly i bind the domain to the mail server ip?
and how it deny at the smtp protocol level?

sorry, but you read the question before answring?

 
Old 09-16-2015, 06:14 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by zohman View Post
but i dont see how it match my needs..
Example, or actual domain, I think you should try it before discarding what you don't "see".
It matches as
Quote:
Originally Posted by xspikx View Post
In that file you can specify:
Code:
/^From: .*@fabrikam\.com/               DISCARD
This way any email coming from that domain would be discarded
I found this answer very interesting and made a comment on my blog to have later, if/when I need it.

Don't knock it until you've tried it, or at least researched the given response.

References:
http://www.postfix.org/header_checks.5.html
http://www.ganino.com/how_to_filter_..._header_checks
http://superuser.com/questions/89628...-with-antispam
 
Old 09-16-2015, 07:16 PM   #5
zohman
LQ Newbie
 
Registered: Sep 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Example, or actual domain, I think you should try it before discarding what you don't "see".
It matches as


I found this answer very interesting and made a comment on my blog to have later, if/when I need it.

Don't knock it until you've tried it, or at least researched the given response.
you joking? try it?
im header_checks writer\exploiter pro,
this is even not a reasonable answer to what i'm after.

Anyway, can some postfix master redeem me?
 
Old 09-17-2015, 08:39 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by zohman View Post
you joking? try it?
im header_checks writer\exploiter pro.
And yet you're here asking us.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
exim and smtp relaying for selected domains dp4qb Linux - Software 0 07-30-2014 12:44 AM
[SOLVED] Postfix- Stop Relaying for Specific Sending Domains jon_the_eye Linux - Server 1 02-13-2013 05:29 AM
Postfix - how do hosted domains download their mail from my postfix franschoek Linux - Software 1 04-01-2006 09:41 PM
Postfix and relaying, help! Sizam Linux - Software 1 04-11-2005 04:37 PM
Securing Multiple Domains on 1 Server jgillin Linux - Security 1 05-10-2004 06:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration