-
1
- #1
Hi!
A daily increasing amount of spam is currently arriving at my site. So i tried to setup an easy way to block it at source.
After taking a look at the log's i noticed 99% spam comes out of taiwan. Neither me nor any of my customers are attempting to receive personal mail from this country. So i decided to block the whole country.
Requirements:
qmail (huh? )
IP::Country Perl-Module (as well as a running perl)
ip2country (pl-script is included in magic-smtpd package, use this one. It's output slightly differs from the original one which is bundled with IP::Country)
and for this example: rblsmtpd (complimentary)
the script also makes use of some additional packages, in most cases you don't need to bother about them cause theyre use is very common.
following is (partly) my
/var/qmail/supervise/qmail-smtpd/run :
---snip-snap---
---snip-snap---
And... sorry, english is not my native language
A daily increasing amount of spam is currently arriving at my site. So i tried to setup an easy way to block it at source.
After taking a look at the log's i noticed 99% spam comes out of taiwan. Neither me nor any of my customers are attempting to receive personal mail from this country. So i decided to block the whole country.
Requirements:
qmail (huh? )
IP::Country Perl-Module (as well as a running perl)
ip2country (pl-script is included in magic-smtpd package, use this one. It's output slightly differs from the original one which is bundled with IP::Country)
and for this example: rblsmtpd (complimentary)
the script also makes use of some additional packages, in most cases you don't need to bother about them cause theyre use is very common.
following is (partly) my
/var/qmail/supervise/qmail-smtpd/run :
---snip-snap---
Code:
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
SMTPALIAS="xxxxx.xxxxxxxxxxx.xxx"
# Blocked Country (Space separated e.g. "TW CN YA", note: uppercase!)
export QM_BLOCKED_COUNTRY="TW CN YA"
export QM_BLOCKED_OUTPUT="550 Sender rejected. See [URL unfurl="true"]http://xxxxx.xxxxxxxxxx.xxx/550spam.html[/URL] for more details."
# Here we're trying to block via rblsmtpd and some country-filter
exec /usr/local/bin/softlimit -m 6000000 /usr/local/bin/tcpserver -v -P -l$SMTPALIAS -x /etc/tcp.smtp.cdb -c $MAXSMTPD -u $QMAILDUID -g $NOFILESGID 0 smtp /usr/local/bin/rblsmtpd -r bl.spamcop.net -r dev.null.dk -r relays.ordb.org -r list.dsbl.org -r orbs.dorkslayers.com -r relays.osirusoft.com sh -c 'ccode=`/var/qmail/bin/scripts/ip2country $TCPREMOTEIP`; test "${QM_BLOCKED_COUNTRY/"\\${ccode:0:1}\\${ccode:1:1}"/yy}" != "$QM_BLOCKED_COUNTRY" && ( echo "$QM_BLOCKED_OUTPUT" ; echo "$QM_BLOCKED_OUTPUT - $ccode" | /var/qmail/bin/splogger ) || /var/qmail/bin/qmail-smtpd' 2>&1
And... sorry, english is not my native language