Postfix 'Relay access denied', hoe te voorkomen?

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • Wtrdk
  • Registratie: Mei 2006
  • Laatst online: 11-03 21:30
Allen,

Ik draai thuis een Ubuntu 14.04 server met daarop een postfix/dovecot installatie. Alles werkt naar behoren, echter zie ik in mail.log meerdere keren per dag het volgende voorbijkomen:
code:
1
Jul 11 12:41:24 www postfix/smtpd[17940]: NOQUEUE: reject: RCPT from 203-113-206-105-static.TCS.netspace.net.au[203.113.206.105]: 554 5.7.1 <mike24@outlook.it>: Relay access denied; from=<joe@535790D4.cm-6-8c.dynamic.ziggo.nl> to=<mike24@outlook.it> proto=ESMTP helo=<souzhaqiri>

Altijd staat die 'mike24@outlook.it' er in, en deze melding staat zo'n 50 keer per dag in de log.
Ik zou graag zien dat ik dit kan voorkomen.

Nu heb ik volgens de instructies van deze site een blacklist/whitelist aangemaakt, maar dat maakt geen verschil.

De inhoud van client_checks (server_checks heb ik dezelfde inhoud gegeven):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#his file must be "compiled" with "postmap"

# Using a domain name
#example.tld             REJECT Spam not tolerated here
# Maybe example2.tld is on a DNSbl, but we want to let their
# email in anyway.
#example2.tld            OK

# We get lots of spam from example3.tld, but we have somebody
# there from which we do want to hear
#someuser@example3.tld   OK
#example3.tld            REJECT
41.21.178.0/24           REJECT Spam not tolerated here
203.231.35.0/24          REJECT Spam not tolerated here
196.46.142.0/24          REJECT Spam not tolerated here
203.113.206.0/24         REJECT Spam not tolerated here
212.54.42.0/24           REJECT Spam not tolerated here
mike24@outlook.it        REJECT Spam not tolerated here


De inhoud van mijn main.cf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
 
# The first text sent to a connecting process.
smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
readme_directory = no
 
# SASL parameters
# ---------------------------------
 
# Use Dovecot to authenticate.
smtpd_sasl_type = dovecot
# Referring to /var/spool/postfix/private/auth
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =
smtpd_sasl_authenticated_header = yes
 
# TLS parameters
# ---------------------------------
 
# Replace this with your SSL certificate path if you are using one.
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
# The snakeoil self-signed certificate has no need for a CA file. But
# if you are using your own SSL certificate, then you probably have
# a CA certificate bundle from your provider. The path to that goes
# here.
#smtpd_tls_CAfile=/path/to/ca/file
smtpd_use_tls=yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_sasl_security_options = noanonymous
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtp_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
 
# SMTPD parameters
# ---------------------------------
 
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
# will it be a permanent error or temporary
unknown_local_recipient_reject_code = 450
# how long to keep message on queue before return as failed.
# some have 3 days, I have 16 days as I am backup server for some people
# whom go on holiday with their server switched off.
maximal_queue_lifetime = 7d
# max and min time in seconds between retries if connection failed
minimal_backoff_time = 1000s
maximal_backoff_time = 8000s
# how long to wait when servers connect before receiving rest of data
smtp_helo_timeout = 60s
# how many address can be used in one message.
# effective stopper to mass spammers, accidental copy in whole address list
# but may restrict intentional mail shots.
smtpd_recipient_limit = 16
# how many error before back off.
smtpd_soft_error_limit = 3
# how many max errors before blocking it.
smtpd_hard_error_limit = 12

# This next set are important for determining who can send mail and relay mail
# to other servers. It is very important to get this right - accidentally producing
# an open relay that allows unauthenticated sending of mail is a Very Bad Thing.
#
# You are encouraged to read up on what exactly each of these options accomplish.
 
# Requirements for the HELO statement
smtpd_helo_restrictions = permit_mynetworks, warn_if_reject, reject_non_fqdn_hostname, reject_invalid_hostname, permit
# Requirements for the sender details
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
# Requirements for the connecting server
smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl, reject_rbl_client dnsbl.njabl.org
# Requirement for the recipient address. Note that the entry for
# "check_policy_service inet:127.0.0.1:10023" enables Postgrey.
smtpd_recipient_restrictions = reject_unauth_pipelining permit_mynetworks permit_sasl_authenticated reject_non_fqdn_recipient reject_unknown_recipient_domain reject_unauth_destination check_policy_service inet:127.0.0.1:10023, check_client_access hash:/etc/postfix/client_checks, check_sender_access hash:/etc/postfix/sender_checks, permit

smtpd_data_restrictions = reject_unauth_pipelining 

# This is a new option as of Postfix 2.10, and is required in addition to
# smtpd_recipient_restrictions for things to work properly in this setup.
#smtpd_relay_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination,  permit

 
# require proper helo at connections
smtpd_helo_required = yes
# waste spammers time before rejecting them
smtpd_delay_reject = yes
disable_vrfy_command = yes
 
# General host and delivery info
# ----------------------------------
 
myhostname = mail.mijndomein.nl
myorigin = /etc/hostname
# Some people see issues when setting mydestination explicitly to the server
# subdomain, while leaving it empty generally doesn't hurt. So it is left empty here.
# mydestination = mail.example.com, localhost
mydestination =localhost
# If you have a separate web server that sends outgoing mail through this
# mailserver, you may want to add its IP address to the space-delimited list in
# mynetworks, e.g. as 111.222.333.444/32.
mynetworks = 192.168.0.0/32 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
mynetworks_style = host
inet_protocols = ipv4
 
# This specifies where the virtual mailbox folders will be located.
virtual_mailbox_base = /var/vmail
# This is for the mailbox location for each user. The domainaliases
# map allows us to make use of Postfix Admin's domain alias feature.
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/mysql_virtual_mailbox_domainaliases_maps.cf
# and their user id
virtual_uid_maps = static:150
# and group id
virtual_gid_maps = static:8
# This is for aliases. The domainaliases map allows us to make 
# use of Postfix Admin's domain alias feature.
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_domainaliases_maps.cf
# This is for domain lookups.
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
 
# Integration with other packages
# ---------------------------------------
 
# Tell postfix to hand off mail to the definition for dovecot in master.cf
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
 
# Use amavis for virus and spam scanning
content_filter = amavis:[127.0.0.1]:10024
 
# Header manipulation
# --------------------------------------
 
# Getting rid of unwanted headers. See: https://posluns.com/guides/header-removal/
header_checks = regexp:/etc/postfix/header_checks
# getting rid of x-original-to
enable_original_recipient = no

relayhost = smtp.mijnrelay.nl




smtpd_relay_restrictions = reject_unauth_pipelining permit_mynetworks permit_sasl_authenticated reject_non_fqdn_recipient reject_unknown_recipient_domain reject_unauth_destination check_policy_service unix:private/policy-spf  permit


alias_maps = hash:/etc/aliases


policy-spf_time_limit = 3600s

Acties:
  • 0 Henk 'm!

  • Croga
  • Registratie: Oktober 2001
  • Laatst online: 16:59

Croga

The Unreasonable Man

Waarom zou je dit willen voorkomen? Volgens mij is dit exact wat je wilt...

Wat er gebeurt is dat er iemand probeert mail via je server te versturen naar een ander domein. Je mailserver weigert dit terecht en logt dat het geweigerd is.

Ik zie hier niets gebeuren wat je niet zou willen.

Acties:
  • 0 Henk 'm!

  • Wtrdk
  • Registratie: Mei 2006
  • Laatst online: 11-03 21:30
Wellicht ben ik te voorzichtig, maar als ik zoveel meldingen zie vertrouw ik het niet zo. Ben ook maar een amateur ;-) Ik ben in ieder geval gerustgesteld.

Acties:
  • 0 Henk 'm!

  • CAPSLOCK2000
  • Registratie: Februari 2003
  • Laatst online: 12:17

CAPSLOCK2000

zie teletekst pagina 888

Eens met Croga, postfix doet precies wat je wil. Als je die meldingen echt irritant vindt dan zou je het IP kunnen blokkeren in je firewall maar volgens mij is dat vechten tegen de bierkaai en staat er morgen iemand anders aan de poort te rammelen.

This post is warranted for the full amount you paid me for it.


Acties:
  • 0 Henk 'm!

  • Kees
  • Registratie: Juni 1999
  • Laatst online: 15:20

Kees

Serveradmin / BOFH / DoC
En omdat je niet wil vechten tegen de bierkaai zet je daar een eigen script tegenover uiteraard ;)

fail2ban kan wat jij wil: http://www.fail2ban.org/wiki/index.php/Postfix

"Een serveradmin, voluit een serveradministrator, is dan weer een slavenbeheerder oftewel een slavendrijver" - Rataplan


Acties:
  • 0 Henk 'm!

  • Wtrdk
  • Registratie: Mei 2006
  • Laatst online: 11-03 21:30
Ah, dat ziet er goed uit. Dit weekend eens experimenteren!

Acties:
  • 0 Henk 'm!

  • Wtrdk
  • Registratie: Mei 2006
  • Laatst online: 11-03 21:30
Ik heb even zitten experimenteren met fail2ban, maar er komen nog steeds 'relay access denied' berichten door.
code:
1
2
3
4
5
6
7
8
Jul 14 13:28:47 www postfix/smtpd[16513]: NOQUEUE: reject: RCPT from unknown[69.193.208.230]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>
Jul 14 12:52:15 www postfix/smtpd[13378]: NOQUEUE: reject: RCPT from LPuteaux-656-01-11-44.w82-127.abo.wanadoo.fr[82.127.142.44]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>
Jul 14 12:31:59 www postfix/smtpd[11471]: NOQUEUE: reject: RCPT from 64-132-114-250.static.twtelecom.net[64.132.114.250]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>
Jul 14 12:30:51 www postfix/smtpd[11471]: NOQUEUE: reject: RCPT from sip.qbsradio.qa[213.130.118.102]: 554 5.7.1 <mike24@outlook.it>: Relay access denied; from=<jonathan@535790D4.cm-6-8c.dynamic.ziggo.nl> to=<mike24@outlook.it> proto=ESMTP helo=<owgsmnrdun>
Jul 14 11:45:10 www postfix/smtpd[7123]: NOQUEUE: reject: RCPT from 79.142.46.196.static.impol.net[196.46.142.79]: 554 5.7.1 <mike24@outlook.it>: Relay access denied; from=<eric@535790D4.cm-6-8c.dynamic.ziggo.nl> to=<mike24@outlook.it> proto=ESMTP helo=<gqviexcapg>
Jul 14 11:32:31 www postfix/smtpd[6066]: NOQUEUE: reject: RCPT from 78.130.81.5.rev.optimus.pt[78.130.81.5]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>
Jul 14 10:50:19 www postfix/smtpd[24193]: NOQUEUE: reject: RCPT from unknown[69.193.208.230]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>
Jul 14 10:29:26 www postfix/smtpd[1238]: NOQUEUE: reject: RCPT from unknown[90.164.124.235]: 554 5.7.1 <inzaclubc@yahoo.es>: Relay access denied; from=<test@live.com> to=<inzaclubc@yahoo.es> proto=ESMTP helo=<[192.168.2.33]>


Ik vermoed dat dit komt omdat er telkens maar 1 bericht doorkomt, en fail2ban pas blokkeert vanaf 3 berichten.
Hieronder mijn postfix.conf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Fail2Ban filter for selected Postfix SMTP rejections
#
#

[INCLUDES]

# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf

[Definition]

_daemon = postfix/smtpd

failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 554 5\.7\.1 .*$
            ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.7\.1 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$
            ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[<HOST>\]: 550 5\.1\.1 .*$
            : NOQUEUE: reject: RCPT from [-._\w]+\[<HOST>\]: 554 5.7.1 Service unavailable; Client host .* blocked using (sbl-xbl.spamhaus.org|combined.njabl.org);
            reject: RCPT from (.*)\[<HOST>\]: 550 5.1.1
            reject: RCPT from (.*)\[<HOST>\]: 450 4.7.1
            reject: RCPT from (.*)\[<HOST>\]: 554 5.7.1

ignoreregex =

# Author: Cyril Jaquier


Heeft iemand nog tips? Of moet ik gewoon ophouden met iets willen blokkeren terwijl het niet nodig is? ;)

Acties:
  • 0 Henk 'm!

  • Thralas
  • Registratie: December 2002
  • Laatst online: 09:17
Dat laatste. Bij een SSH-server kun je de boel nog firewallen met een whitelist, dat is onmogelijk met een mailserver waarop je inkomende mail verwacht.

Bovendien zie ik het nut van fail2ban ook niet echt, je kunt pas bannen na een eerste attempt, maar voor een spammer is het nogal zinloos om meer dan eens te connecten, aan die 'relay access denied' verandert weinig (in tegenstelling tot iemand die een hoop verschillende passwords probeert op je SSH-server).

Acties:
  • 0 Henk 'm!

  • Beuker
  • Registratie: December 2000
  • Laatst online: 29-05 08:51
Thralas schreef op maandag 14 juli 2014 @ 14:02:
Bovendien zie ik het nut van fail2ban ook niet echt, je kunt pas bannen na een eerste attempt, maar voor een spammer is het nogal zinloos om meer dan eens te connecten, aan die 'relay access denied' verandert weinig (in tegenstelling tot iemand die een hoop verschillende passwords probeert op je SSH-server).
Wel degelijk is er nut van Fail2Ban! Spammers proberen soms meerdere domeinen/e-mail adressen. Als je er zo eentje te pakken hebt kun je ze gewoon een dag in de firewall laten zetten om te blocken. Blijft je postfix lekker rustig van.

Acties:
  • 0 Henk 'm!

  • Thc_Nbl
  • Registratie: Juli 2001
  • Laatst online: 21-05 22:24
postfix greylist installeren en deze implementeren
https://posluns.com/guides/classes/

SPF checks activeren en fail2ban erbij. ik heb nog maar 0.1% wat gezien word als spam op de anti spam server zo.
an die mike@hotmail.it die zie ik ook zo af en toe maar wordt toch geblokkeerd.
lekker laten gaan..
en als je geen verbindingen wilt die vanaf het tor netwerk komen.

deze erbij.
#!/bin/sh

YOUR_IP=Je_externe_ip

SETTORIPLIST=tor-ip-list.txt
SETTORIPPATH=/home/tor

## Create IP Set
ipset -q create tor hash:ip -exist

# get a list of Tor exit nodes that can access YOUR_IP and write it to a file.
wget -q https://check.torproject....lkExitList.py?ip=$YOUR_IP -O - > $SETTORIPPATH/$SETTORIPLIST

# add each IP address to the new set, silencing the warnings for IPs that have already been added
for x in `cat $SETTORIPPATH/$SETTORIPLIST` ;
do ipset -q add tor $x -exist ;
done

# filter our new set in iptables
iptables -A INPUT -m set --match-set tor src -j DROP

deze draai je 1 keer.
voor een cronjob je, ( die ik elke dag draai )
deze eruit: #ipset -q create tor hash:ip -exist
en deze
#iptables -A INPUT -m set --match-set tor src -j DROP
die staan al in je firewall als bij de eerste keer starten van het bovenstaande script.

ehhh.. noppes


Acties:
  • 0 Henk 'm!

  • Thc_Nbl
  • Registratie: Juli 2001
  • Laatst online: 21-05 22:24
ow en als je je postfix nog meer op RFC instellingen laat checken.
dit klopt niet : helo=<souzhaqiri>
hostname moet een FQDN zijn en resolvable.
ja, dan krijg je meldingen van mensen waarbij de mail geweigerd wordt, maar laat die maar conform RFC de boel instellen..
Je zult zien dat veel mensen met exchange een helo geven met b.v. exchange.domain.local.
( .local is een gereserverd subdomain van Apple ( multicast dns) wat al niet goed is maar goed.
daar hoort dus niets te staan van server.domain.tld.

ehhh.. noppes

Pagina: 1