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 08-28-2013, 03:58 AM   #1
gdr
Member
 
Registered: Jun 2013
Distribution: Mint KDE
Posts: 44

Rep: Reputation: Disabled
postfix: Block certain SMTP clients


I've identified two hosts which regularly spam my users, yet come undetected by spam filters. They're ran by "newsletter" companies which have really good deliverability rate and thus use proper RDNS.

So I tried blocking them in smtp_header_checks like this:

Code:
/^Received: .*\.inis\.pl/                       REJECT Spamerzy wypierdalac!
/^Received: .*\.freshmail\.pl/                  REJECT Spamerzy wypierdalac!
But obviously this didn't work - the Received headers are created further in the pipeline.

How do I block certain remote hosts from connecting based on their RDNS, without resorting to iptables and IP-level blocks?
 
Old 08-28-2013, 05:12 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
i think you meant to use header_checks, not smtp_header_checks, since the smtp_*_checks are done only for outgoing mail.

but, i would try do the filtering at connection time, with smtpd_client_restrictions, or based on MAIL FROM, with smtpd_sender_restrictions. i think that the MAIL FROM value gets copied into the Received header anyway.
 
1 members found this post helpful.
Old 08-28-2013, 09:09 AM   #3
gdr
Member
 
Registered: Jun 2013
Distribution: Mint KDE
Posts: 44

Original Poster
Rep: Reputation: Disabled
The MAIL FROM command wouldn't do it, these operators send emails from many domains, but it's always the same set of mail servers with the same RDNS.

But thank you for header_checks! I have the gift of misunderstanding Postfix documentation every time I read it
 
Old 08-28-2013, 09:21 AM   #4
gdr
Member
 
Registered: Jun 2013
Distribution: Mint KDE
Posts: 44

Original Poster
Rep: Reputation: Disabled
I've found exactly what I needed - it's called check_client_access and works like this (borrowed from Nixcraft forums):

/etc/postfix/main.cf
Code:
smtpd_recipient_restrictions =
	permit_mynetworks
	permit_sasl_authenticated
	reject_unauth_destination
	etc....
	check_client_access regexp:/etc/postfix/blacklist_clients
	etc..
	permit
/etc/postfix/blacklist_clients
Code:
# IP
/^10\.10\.1\.2$/		REJECT UCE black-listed
# IP block
/^10\.10\.1/			REJECT UCE black-listed
# exact domain
/^example\.com$/		REJECT UCE black-listed
# everything in a domain
/example\.com$/			REJECT UCE black-listed
# specific hosts
/^uce-relay\.example\.com$/	REJECT UCE black-listed
 
Old 08-28-2013, 07:40 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
good job. ignore my comment on MAIL FROM being copied to Received. that was nonsense.
 
  


Reply

Tags
postfix



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
[SOLVED] Postfix: SMTP Relay Access Denied with external auth'd clients Gargravarr2112 Linux - Server 4 01-17-2016 12:36 PM
POSTFIX SMTP banner based on MX hostname (PostFix 2.3.3 on RHEL) samarudge Linux - Server 1 02-15-2011 01:59 AM
Smtp server in C : problem with windows clients fredbull Programming 3 06-21-2006 03:11 AM

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

All times are GMT -5. The time now is 08:43 AM.

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