[Adicionando as regras anti-relay e anti-spam]-[Rev 1.1 - Mon Oct 11 10:46:02 1999]
1° PASSO:
Logue Como root na maquina.
2° PASSO:
Crie um diretório e copie seu SENDMAIL.CF (arquivo de configuracao do sendmail) para ele.
$~# mkdir /anti-spam
$~# cd /anti-spam
$~# cp /etc/sendmail.cf /anti-spam
3° PASSO:
Apos ter criado o diretório e copiado o SENDMAIL.CF, pegue as regras anti-spam disponiveis
nesta mesma pagina (regras.tar.gz) e descompacte-as no
diretório /anti-spam.
$~# gunzip regras.tar.gzEsta ação vai gerar dois arquivos:
$~# tar -vxf regras.tar
regras1.txt
regras2.txt
4° PASSO:
Edite o SENDMAIL.CF que está no diretório anti-spam e adicione as regras.
$~# pico /anti-spam/sendmail.cfOk, uma vez dentro do 'PICO' você deve ir para a linha abaixo de 'localhost'. Para adicionar as regras, use o seguinte comando do PICO:
^R (CTRL + R)e lá procure pelo primeiro arquivo (regras1.txt).
##################
# local info #
##################
Cwlocalhost
# Regras Anti Relay hosts
F{LocalIP} /etc/mail/LocalIP
F{RelayTo} /etc/mail/relayto
F{DeniedIP} -o /etc/mail/DeniedIP
F{DeniedNames} -o /etc/mail/DeniedNames
Kjunk hash -a@JUNK /etc/mail/junk
Ok, agora salve o seu arquivo. Vamos para o próximo passo.
5° PASSO:
Agora vamos adicionar o arquivo (regras2.txt)
$~# pico /anti-spam/sendmail.cfCom o arquivo editado, procure por RULESET 98. (lembre-se que para procurar com o pico use o comando):
###################################################################
### Ruleset 98 -- local part of ruleset zero (can be null) ###
###################################################################
Scheck_rcpt
# make sure you have TABs here, not BLANKs! sendmail will complain
otherwise...
# first: get client addr
R$+ $: $(dequote "" $&{client_addr} $) $| $13
R0 $| $* $@ ok no client addr: directly
invoked
R$={LocalIP}$* $| $* $@ ok from here
# not local, check rcpt
R$* $| $* $: $>3 $2
# remove local part, maybe repeatedly
R$*<@$=w.>$* $>3 $1 $3
# alternatively (or even both):
# if you use RelayTo, uncomment the next line!
# R$*<@$*$={RelayTo}.>$* $>3 $1 $4
# still something left?
# R$*<@$+>$* $#error $@ 5.7.1 $: 551 we do not relay
R$*<@$+>$* $#error $@ 5.7.1 $: 551 Relay Negado - Contate o
Administrador de seu sistema.
Scheck_relay
R$+ $| $={DeniedIP}$* $#error $@ 5.7.1 $: "no access from your
IP address"
R$*$={DeniedNames} $| $* $#error $@ 5.7.1 $: "no access from your
host"
# check for junk domain/spammers
Sjunk
# lookup domain in database
R$*<@$+> $:$1<@$(junk $2$)>
# exists? return
R$*<@JUNK@JUNK> $@$1<@ "551 mail from your spam domain not
accepted." @JUNK>
R$*<@$*@JUNK> $@$1<@$2@JUNK>
# lookup address in database
R$*<@$+> $:$1<@$(junk $1@$2 $:$2$)>
# exists? return
R$*<@SPAMMER@JUNK> $@$1<@ "551 mail from your spam address not
accepted." @JUNK>
R$*<@$*@JUNK> $@$1<@$2@JUNK>
# remove one subdomain, try again
R$*<@$-.$-.$+> $: $>junk $1<@$3.$4>
Scheck_mail
# don't check these
R<$*@$=w> $@ ok shortcut
# idea from Steven Schultz
R<> $: <$n @ $(dequote "" $&{client_name} $) >
# mark address
#R$* $:<@>$1
# is the syntax ok (uses <> and no dot at the end?)
#R<@><$*@$*$~.> $:<$1@$2$3>
# mark still there: error...
#R<@>$* $#error $@ 5.1.8 $: 551 illegal MAIL FROM $1,
# if we don't to the above: remove at least the dot...
R<$*@$*.> <$1@$2>
R$* $: $>3 $1 canonify
R$- $@ ok local host
# no host without a . in the FQHN ?
# if you get local e-mail from hosts without full domains,
# put a hash in front of the next rule
R$*<@$->$* $#error $@ 5.1.8 $: 551 invalid host name $2, check your
configuration.
# lookup IP address (reverse mapping available?)
# R$*<@[$-.$-.$-.$-]>$* $: $1 < @ $[ [ $2.$3.$4.$5 ] $] > $6
# copy the result of the lookup
R$* $:$1 $| $1
# now remove the dot
R$* $| $*<@$*.>$* $: $1 $| $2<@$3>$4
# and check the database
R$* $| $*<@$*>$* $: $1 $| $>junk $2<@$3>
# match: return given error code (rhs of map)
R$* $| $*<@$*@JUNK>$* $#error $@ 5.7.1 $: $3
# restore original value (after canonicalization by ruleset 3)
# this is only required if you want to enable the last rule
# R$* $| $* $: $1
# this is dangerous! no real name
# R$*<@$*$~P>$* $#error $@ 4.1.8 $: 451 unresolvable host name $2$3,
check your setup.
S98
Salve seu SENDMAIL.CF.
6° PASSO:
Crie um diretório chamado mail dentro do diretório /ETC
$~# mkdir /etc/mailEm seguida crie os seguintes arquivos:
$~# cd /etc/mail
$~# echo > LocalIP
$~# echo > relayto
$~# echo > DeniedIP
$~# echo > DeniedNames
$~# echo > junk
LocalIP -> Deve conter o ip de suas maquinas
ex:
127.0.0.1
2.34.56.78
2.34.56.78.
2.34.56
relayto -> Deve conter o IP e HOSTS das maquinas que podem fazer 'RELAY'
pelo seu servidor
ex:
www.minha-maquina.com
www.xyz.org
222.54.22.09
2.34.56.78
DeniedIP -> Deve conter o IP das maquinas que estao banidas por você
ex:
2.34.56.78
222.234.244.555
DeniedNames -> Deve conter o DOMINIO das maquinas banidas por você
ex:
www.happens.org
www.disneylandia.com
pornografia.net
junk -> Deve conter hosts e nomes de usuarios banidos
ex:
mickey@disneylandia.com "551 ISSO AQUI NAO E A DISNEYLANDIA !!"
@xyz.com "551 Bloqueado"
so.what.com "você esta banido"
so.what.com "551 oi spammers"
Determinando seus IPs banidos e IPs habilitados você tem de gerar
um pequeno banco de dados:
$~# makemap -v hash LocalIP.db < LocalIP (opcional)
$~# makemap -v hash relayto.db < relayto (opcional)
$~# makemap -v hash DeniedNames.db < DeniedNames
$~# makemap -v hash DeniedIP.db < DeniedIP
$~# makemap -v hash junk.db < junk
Obs: Alguns Sistemas Operacionais (OS) nao aceitam 'HASH' você
pode usar 'DBM', 'BTREE', nao se esqueca somente de alterar as PRIMEIRAS
REGRAS. Trocando a o comando 'HASH' por qualquer um dos descritos acima.
7° PASSO:
Crie um diretório chamado 'SEND-ORIG'
$~# mkdir /etc/send-orig
$~# cp /etc/sendmail.cf /etc/send-orig
Chegamos no CLIMAX da instalação. Agora você deve derrubar seu sendmail e por seu novo .CF para funcionar.
$~# killall sendmailSe tudo der certo seu sendmail com regras anti-spam estarao no ar, para certifica-se disso de um telnet para sua porta 25.
$~# rm /etc/sendmail.cf
$~# cp /anti-spam/sendmail.cf /etc/
$~# /usr/sbin/sendmail -bd -q 15m
$~# telnet localhost 25
220 sua.makina.com.br xxxxxxxxxxxxxx
Caso nao de certo, derrube seu sendmail mais uma vez e volte as configuracoes antigas, e envie-nos um e-mail.
$~# rm /etc/sendmail.cf
$~# cp /etc/send-orig/sendmail.cf /etc
$~# /usr/sbin/sendmail -bd -q 15m
Abracos,
__
Alvaro Nascimento
Obs: Estas regras estao originalmente em
http://www.sendmail.org/~ca/email/check.html.
Copyright © Claus Aßmann Please send comments to: ca@sendmail.org
[VOLTAR] [PÁGINA INICIAL]