Vasili Sviridov
Vasili Sviridov

Reputation: 301

Block incoming connections with hostnames that contain IP addresses

I used to run qmail with spamdyke, and spamdyke has a nifty ability to block incoming mail if the host looks like these:

static-68-179-34-50.ptr.terago.net
c-75-74-22-18.hsd1.fl.comcast.net
173-14-159-121-newengland.hfc.comcastbusiness.net
rrcs-24-43-130-226.west.biz.rr.com
va-65-40-217-136.sta.embarqhsd.net
unused-66-33-224-181.unused.epix.net
c-67-190-66-10.hsd1.co.comcast.net

Basically, it had some form of the IP addres in the hostname, which usually designates dynamic clients, et cetera. Since they have no reason to try to send mail directly to my SMTP server, they can be considered spammers with 99.99% certainty.

What is the easiest way to achieve same functionality with postfix?

http://www.spamdyke.org/documentation/README.html#RDNS

Upvotes: 2

Views: 2709

Answers (1)

higuita
higuita

Reputation: 2315

Usually its safer to use the spamhaus PBL, but you can do this with

smtpd_helo_restrictions = reject_invalid_hostname,  check_helo_access regexp:/etc/postfix/helo.regexp

in the helo.regexp add

/[0-9]+-[0-9]+-[0-9]+-[0-9]+[.-@]/  REJECT

You can fine tune it if you want, or use PCRE instead (dont forget to update the format in the smtpd_helo_restrictions line)

Upvotes: 2

Related Questions