exim4:access_control
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
exim4:access_control [2016/11/04 10:21] – peter | exim4:access_control [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 26: | Line 26: | ||
</ | </ | ||
+ | <WRAP warning> | ||
**WARNING**: | **WARNING**: | ||
+ | </ | ||
Line 40: | Line 42: | ||
# If the HELO pretend to be this host | # If the HELO pretend to be this host | ||
deny condition = ${if or { \ | deny condition = ${if or { \ | ||
- | {eq {${lc: | + | {eq {${lc: |
- | {eq {${lc: | + | {eq {${lc: |
} {true}{false} } | } {true}{false} } | ||
Line 47: | Line 49: | ||
accept | accept | ||
</ | </ | ||
+ | |||
===== Remote host IP checking ===== | ===== Remote host IP checking ===== | ||
- | Allow connections from our own hosts and a white-list (Some hosts from big internet providers) with no more check. | + | Allow connections from our own hosts and a white-list (Some hosts from big internet providers) with no more check. |
< | < | ||
Line 65: | Line 68: | ||
- | ====== Remote host IP checking by DNS black-list | + | ===== Remote host IP checking by DNS black-list ===== |
Hosts listed by the dns list **sbl-xbl.spamhaus.org** are spammers or relays for spams. | Hosts listed by the dns list **sbl-xbl.spamhaus.org** are spammers or relays for spams. | ||
Line 76: | Line 79: | ||
dnslists = sbl-xbl.spamhaus.org | dnslists = sbl-xbl.spamhaus.org | ||
</ | </ | ||
+ | | ||
+ | |||
+ | |||
+ | ===== Sender checking ===== | ||
+ | |||
+ | To refuse some senders. | ||
+ | |||
+ | < | ||
+ | acl_check_sender: | ||
+ | deny senders = / | ||
+ | accept | ||
+ | </ | ||
| | ||
===== Sender Address or Remote Host ACL ===== | ===== Sender Address or Remote Host ACL ===== | ||
Line 97: | Line 112: | ||
| | ||
This example uses two plain text files as blacklists. | This example uses two plain text files as blacklists. | ||
+ | |||
+ | |||
+ | ===== Recipient: no hack ===== | ||
+ | |||
+ | (From / | ||
+ | |||
+ | Deny if the local part contains @ or % or / or | or !. These are rarely found in genuine local parts, but are often tried by people looking to circumvent relaying restrictions. | ||
+ | |||
+ | Also deny if the local part starts with a dot. Empty components aren't strictly legal in RFC 2822, but Exim allows them because this is common. | ||
+ | |||
+ | < | ||
+ | acl_check_rcpt: | ||
+ | . . . | ||
+ | # refuse if the recipient string is a hack, | ||
+ | # see exim file example C043.txt.gz | ||
+ | deny | ||
+ | local_parts = ^.*[@%!/|] : ^\\. | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Recipient: no relay ===== | ||
+ | |||
+ | I refuse to relay spams: | ||
+ | |||
+ | < | ||
+ | acl_check_rcpt: | ||
+ | . . . | ||
+ | # For the rest, the domain of the recipient address | ||
+ | # must be my public domain. (no relay) | ||
+ | require | ||
+ | log_message = no relay. | ||
+ | domains | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Recipient: manual redirect by the sender ===== | ||
+ | |||
+ | The idea is to send an automatic reply, using " | ||
+ | |||
+ | In a filter: | ||
+ | |||
+ | < | ||
+ | ### reply for someone@msharewiz.net | ||
+ | if $original_local_part is " | ||
+ | seen mail from drop@sharewiz.net subject "Re: $h_subject" | ||
+ | finish | ||
+ | endif | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Recipient: emails addresses to catch spams ===== | ||
+ | |||
+ | You can publish a sacrified email address in a web page to trap spammers (some spammers crawl other web pages to get emails). | ||
+ | |||
+ | When you write to a suspicious company wich could send you spam or when you write in a newsgroup, you can use a special email, with date (like echant-td-n040531@sharewiz.net) or with an included identifier (like echant-tr-lemonde@sharewiz.net). | ||
+ | |||
+ | < | ||
+ | acl_check_rcpt: | ||
+ | . . . | ||
+ | drop | ||
+ | log_message | ||
+ | recipients = / | ||
+ | </ | ||
+ | |||
+ | |||
+ | I use this script in cron.daily/ to update my emails with a date incorporated. | ||
+ | |||
+ | <code bash / | ||
+ | #!/bin/bash | ||
+ | # | ||
+ | # Update my email to include todays date. | ||
+ | set -e | ||
+ | T=$(tempfile) | ||
+ | D=$(date ' | ||
+ | |||
+ | function mod_file { | ||
+ | EMAIL=" | ||
+ | LETTRE=" | ||
+ | CONF=" | ||
+ | if [ -f " | ||
+ | lockfile-create " | ||
+ | sed " | ||
+ | cp " | ||
+ | lockfile-remove " | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | # The first line will replace echant-td-n040625@sharewiz.net | ||
+ | # with echant-td-n040626@sharewiz.net | ||
+ | mod_file echant n / | ||
+ | mod_file echant e / | ||
+ | mod_file echant e / | ||
+ | # For apache we should reload but it is done by | ||
+ | # logrotate from time to time. | ||
+ | mod_file echant w / | ||
+ | |||
+ | rm $T | ||
+ | </ | ||
Line 115: | Line 228: | ||
accept | accept | ||
</ | </ | ||
- | | + | |
+ | |||
+ | ===== Greylist ===== | ||
+ | |||
+ | Greylisting use the fact that most of the time spammers softwares do not take account tempory errors to retry later. | ||
+ | |||
+ | When exim send a " | ||
+ | |||
+ | * Not if the host is in a white list of " | ||
+ | * Not if there is no sender: it is a bounce message. | ||
+ | * Not if the HELO argument is well configured and the host name seams owned by the sender. | ||
+ | * if the greylist daemon want to. | ||
+ | |||
+ | The two lines with **set acl_m9** are used to send the request to the daemon and get the result. | ||
+ | |||
+ | < | ||
+ | ###################################################################### | ||
+ | # MAIN CONFIGURATION SETTINGS | ||
+ | ###################################################################### | ||
+ | # Mandatory to use " | ||
+ | helo_try_verify_hosts = !+own_hosts | ||
+ | . . . | ||
+ | ###################################################################### | ||
+ | # ACL CONFIGURATION | ||
+ | ###################################################################### | ||
+ | # ACL " | ||
+ | # hosts which have not their own registered domain-name (probably spammer). | ||
+ | # Return ok if the HELO argument correspond to the connected HOST and | ||
+ | # if the argument does not contain an IP in decimal or hexa. | ||
+ | # I have created this ACL subroutine because we can't do a list of " | ||
+ | # in ACL (it's a list of " | ||
+ | # no (no A and no B) = A or B. | ||
+ | acl_clean_helo: | ||
+ | accept | ||
+ | verify | ||
+ | condition | ||
+ | |||
+ | |||
+ | acl_check_rcpt: | ||
+ | . . . | ||
+ | |||
+ | # Greylisting, | ||
+ | # a dialin name (with IP included in the name). Some hosts from big | ||
+ | # providers are in a white list to avoid testing. When there is no | ||
+ | # sender then it is a bounce message, so no greylist. | ||
+ | | ||
+ | message = Please try later. | ||
+ | !hosts | ||
+ | !senders | ||
+ | !acl = acl_clean_helo | ||
+ | log_message = greylisted. | ||
+ | set acl_m9 | ||
+ | set acl_m9 | ||
+ | condition | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Anti-virus: Windows executable in attachment ===== | ||
+ | |||
+ | It's a very basic anti-virus: every emails with a windows executable as attachment is rejected. | ||
+ | |||
+ | < | ||
+ | acl_check_data: | ||
+ | . . . | ||
+ | deny message = This message contains an attachment of a type which we do not accept (.$found_extension) | ||
+ | demime = bat: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== anti-virus: clamav ===== | ||
+ | |||
+ | < | ||
+ | ###################################################################### | ||
+ | # MAIN CONFIGURATION SETTINGS | ||
+ | ###################################################################### | ||
+ | av_scanner = clamd:/ | ||
+ | . . . | ||
+ | ###################################################################### | ||
+ | # ACL CONFIGURATION | ||
+ | ###################################################################### | ||
+ | acl_check_data: | ||
+ | . . . | ||
+ | deny message = This message contains a virus or other harmful content ($malware_name) | ||
+ | demime = * | ||
+ | malware = * | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | anti-spam external detector: spamassassin | ||
+ | |||
+ | We add a " | ||
+ | |||
+ | Because of the " | ||
+ | |||
+ | < | ||
+ | ###################################################################### | ||
+ | # MAIN CONFIGURATION SETTINGS | ||
+ | ###################################################################### | ||
+ | spamd_address = 127.0.0.1 783 | ||
+ | . . . | ||
+ | ###################################################################### | ||
+ | # ACL CONFIGURATION | ||
+ | ###################################################################### | ||
+ | acl_check_data: | ||
+ | . . . | ||
+ | ## spamassassin, | ||
+ | ## limit its use under 500k. | ||
+ | accept | ||
+ | warn message = X-SA-Score: $spam_score | ||
+ | spam = nobody:true | ||
+ | warn message = X-SA-Report: | ||
+ | spam = nobody: | ||
+ | condition = ${if > | ||
+ | warn message = X-SA-Status: | ||
+ | spam = nobody: | ||
+ | condition = ${if > | ||
+ | deny message = This message scored $spam_score spam points. | ||
+ | spam = nobody:true | ||
+ | condition = ${if > | ||
+ | </ | ||
+ | |||
+ | In your " | ||
+ | |||
+ | <file bash ~/ | ||
+ | # Exim filter | ||
+ | if $h_X-SA-Status: | ||
+ | save $home/ | ||
+ | | ||
+ | endif | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Checking source of email associated with your domain in whois ===== | ||
+ | |||
+ | If you have an email published in a whois database (spammers scan these databases) but want emails just from your registrar, you can add this in your " | ||
+ | |||
+ | <file bash ~/ | ||
+ | # Exim filter | ||
+ | if $original_local_part is " | ||
+ | then | ||
+ | if $sender_address_domain is " | ||
+ | deliver john | ||
+ | else | ||
+ | save $home/ | ||
+ | finish | ||
+ | endif | ||
+ | endif | ||
+ | </ |
exim4/access_control.1478254889.txt.gz · Last modified: 2020/07/15 09:30 (external edit)