Contribution: regex rules for "bad" hostname patterns
2013-08-11 by Jim Klimov
Hello all,
I've ported into milter-greylist regex capabilities some rules from
our milter-regex setup (much time has passed, so I am not sure if
these rules were authored by myself or by someone from that project).
I hope the rules and comments near them are quite self-explanatory.
Use/adopt with due care, and have fun :)
By the way, is there any option and format string to set and report
in "msg" clauses the "contact" address for this server's postmaster,
so that collateral casualties might ask for them to be whitelisted?
Probably it should be (automatically?) whitelisted as an RCPT rule.
So far this example hardcodes "abuse@...", but a macro would
be a lot neater here ;)
# cat milter-greylist.conf-80-regex-DUL
### This blocks dial-up and other consumer addresses based on remote
### host's domain name which "seems like" a typical dial-up address.
### $Id: $
### Use extended regular expressions instead of basic regular
### expressions.
extendedregex
### Try to ensure bracketed numeric IP addresses are resolved into names
unbracket
### Reject (delay) unresolvable mailservers (hostname is IP in brackets)
### The short delay along with flushaddr allows to quickly recover from
### temporary DNS errors, but keeps really unresolvable sources from
### delivering mail to us. True servers are registered at least somehow!
racl greylist \
domain /^\[[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\]$/ \
delay 1m flushaddr \
msg "(CONNECT) DNS PTR could not be resolved. Please try again
later or re-post through an SMTP server properly registered in DNS, or
contact abuse@.... IP:'%i' DOMAIN:'%d' HELO:'%h' FROM:'%f' RCPT:'%r'"
### Reject (delay) relays with malformed HELO or DNS PTR names
### (not FQDN)
racl greylist helo /^[^\.]*$/ delay 60m msg "Malformed HELO ('%h' not a
fully-qualified domain name: no dot)"
racl greylist domain /^[^\.]*$/ delay 60m msg "Malformed DNS PTR ('%d'
not a fully-qualified domain name: no dot)"
### Reject (delay) things that look like they might come from a dynamic
### "consumer" or "dial-up" address, if this was not filtered by DULRBL.
### So, we reject anything that has three digit sets deperated by a
### dash, (ie adsl-134-11-333-11.someisp.net). We reject anything that
### has 3+ numeric subdomains, (ie dialup.123.45.67.8.someisp.net).
### And finally reject any address that has a group of 12 digits,
### (ie pool123045067003.someisp.net).
list "dynamicDomainNames" domain { \
/^.*[0-9][0-9]*\-[0-9][0-9]*\-[0-9][0-9]*.*$/ \
/^[^\[].*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*.*[^\]]$/ \
/^.*[0-9]{12}.*$/e \
/^.*ppp[0-9\.\-].*$/i \
/^.*pool[0-9\.\-].*$/i \
/^.*dsl[0-9\.\-].*$/i \
/^.*dial[0-9\.\-].*$/i \
/^.*dial-?up[0-9\.\-].*$/i \
/^.*dynamic[0-9\.\-].*$/i \
/^.*cable[0-9\.\-].*$/i \
/^.*client[0-9\.\-].*$/i \
/^.*host[0-9\.\-].*$/i \
/^.*dhcp[0-9\.\-].*$/i \
/^.*cdma[0-9\.\-].*$/i \
/broadband/i \
/static/i \
/^.*in-addr\.arpa.*$/i \
/^.*dip0\.t-ipconnect\.de$/i \
/^.*virtua\.com\.br$/i \
/speedy.com.ar$/i \
}
racl greylist list "dynamicDomainNames" delay 120m \
msg "(CONNECT) Your hostname DNS PTR entry looks like a
dynamic/consumer address, please re-send through your ISP's registered
SMTP server, or contact abuse@.... IP:'%i' DOMAIN:'%d' HELO:'%h'
FROM:'%f' RCPT:'%r'"
### Above we rejected (delayed long enough to get hit by DNS RBL)
### potential spammers by IP-looking names and by dynamic-looking
### names...
Hope this helps,
//Jim Klimov