Server-Konfiguration · 4 min read · Oct 07, 2025

Mandriva Directory Server Auf Debian Etch - Seite 3

8 SASL-Konfiguration

Postfix wird SASL verwenden, um Benutzer gegen den LDAP-Server zu authentifizieren.

mkdir -p /var/spool/postfix/var/run/saslauthd/

Passen Sie die Standardeinstellungen an.

vi /etc/default/saslauthd

Es sollte so aussehen:

START=yes
MECHANISMS="ldap"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
vi /etc/saslauthd.conf

Es sollte so aussehen:

ldap_servers: ldap://127.0.0.1
ldap_search_base: ou=Users,dc=example,dc=com
ldap_filter: (&(objectClass=mailAccount)(mail=%u@%r)(mailenable=OK))
vi /etc/postfix/sasl/smtpd.conf

Es sollte so aussehen:

pwcheck_method: saslauthd
mech_list: plain login

Fügen Sie Postfix zur SASL-Gruppe hinzu …

adduser postfix sasl

… und starten Sie SASL neu.

/etc/init.d/saslauthd restart

9 Postfix-Konfiguration

9.1 Beispielkonfiguration

Für dieses Setup habe ich die Konfiguration ohne virtuelle Domains gewählt - vielleicht werde ich in naher Zukunft die erforderlichen Schritte für eine virtuelle Domain-Konfiguration hinzufügen. Zuerst kopieren Sie die Beispielkonfigurationsdatei in das Postfix-Verzeichnis. Es ist die Basis für die folgende Konfiguration.

cp /usr/share/doc/python-mmc-base/contrib/postfix/no-virtual-domain/* /etc/postfix/

9.2 Hauptkonfiguration

Zuerst passen Sie die Hauptkonfigurationsdatei an.

vi /etc/postfix/main.cf

Bearbeiten Sie die Datei, sodass sie zu Ihrer Domain passt, und fügen Sie zusätzlich einige Einschränkungen und die Authentifizierungseinstellungen hinzu - der Inhalt sollte so aussehen:

# Siehe /usr/share/postfix/main.cf.dist für eine kommentierte, vollständigere Version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no  

# Das Anhängen von .domain ist die Aufgabe des MUA.
append_dot_mydomain = yes
append_at_myorigin = yes  

# Kommentieren Sie die nächste Zeile aus, um "verzögerte E-Mail"-Warnungen zu generieren
#delay_warning_time = 4h  

myhostname = server1.example.com
mydomain = example.com
alias_maps = ldap:/etc/postfix/ldap-aliases.cf,  hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = server1.example.com,example.com,localhost.localdomain,localhost
mail_destination_recipient_limit = 1
mailbox_command = /usr/lib/dovecot/deliver -d "$USER"@"$DOMAIN"
relayhost = 
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all  

# Verwenden Sie Maildir
home_mailbox = Maildir/  

# Warten Sie bis zum RCPT TO-Befehl, bevor Sie Einschränkungen bewerten
smtpd_delay_reject = yes  

# Grundlagen Einschränkungen 
smtpd_helo_required = yes 
strict_rfc821_envelopes = yes  

# Anforderungen für den verbindenden Server 
smtpd_client_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_rbl_client bl.spamcop.net, 
   reject_rbl_client dnsbl.njabl.org, 
   reject_rbl_client cbl.abuseat.org, 
   reject_rbl_client sbl-xbl.spamhaus.org, 
   reject_rbl_client list.dsbl.org, 
   permit  

# Anforderungen für die HELO-Anweisung 
smtpd_helo_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_hostname, 
   reject_invalid_hostname, 
   permit  

# Anforderungen für die Absenderadresse 
smtpd_sender_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_sender, 
   reject_unknown_sender_domain, 
   permit  

# Anforderungen für die Empfängeradresse 
smtpd_recipient_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_recipient, 
   reject_unknown_recipient_domain, 
   reject_unauth_destination, 
   permit  

# Aktivieren Sie die SASL-Authentifizierung für den smtpd-Daemon 
smtpd_sasl_auth_enable = yes 
smtpd_sasl_type = dovecot 
smtpd_sasl_path = private/auth  

# Fix für Outlook
broken_sasl_auth_clients = yes  

# Anonyme Verbindungen ablehnen 
smtpd_sasl_security_options = noanonymous 
smtpd_sasl_local_domain =  

# SSL/TLS
smtpd_tls_security_level = may 
smtpd_tls_loglevel = 1 
smtpd_tls_cert_file = /etc/ssl/certs/mail.pem 
smtpd_tls_key_file = /etc/ssl/private/mail.key
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache  

# Amavis
content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings

9.3 LDAP-Alias-Konfiguration

Jetzt müssen Sie die Alias-Konfiguration bearbeiten.

vi /etc/postfix/ldap-aliases.cf

Bearbeiten Sie die Datei, sodass sie zu Ihrer Domain passt - sie sollte so aussehen:

server_host = 127.0.0.1
search_base = ou=Users,dc=example,dc=com
query_filter = (&(objectClass=mailAccount)(mailalias=%s)(mailenable=OK))
result_attribute = maildrop
version = 3

9.4 Master-Konfiguration

Die Master-Konfiguration ist der letzte Teil der Postfix-Konfiguration.

vi /etc/postfix/master.cf

Fügen Sie die folgenden Zeilen hinzu:

# SMTPS  
smtps inet n - - - - smtpd  
   -o smtpd_tls_wrappermode=yes  
   -o smtpd_sasl_auth_enable=yes
# Dovecot  
dovecot unix - n n - - pipe  
   flags=DRhu user=dovecot:mail argv=/usr/lib/dovecot/deliver -d $recipient
# Mail an Amavis  
amavis unix - - - - 10 smtp  
   -o smtp_data_done_timeout=1200  
   -o smtp_send_xforward_command=yes  
   -o disable_dns_lookups=yes  
   -o max_use=20
# Mail von Amavis  
127.0.0.1:10025 inet n - - - - smtpd  
   -o content_filter=  
   -o local_recipient_maps=  
   -o relay_recipient_maps=  
   -o smtpd_restriction_classes=  
   -o smtpd_delay_reject=no  
   -o smtpd_client_restrictions=permit_mynetworks,reject  
   -o smtpd_helo_restrictions=  
   -o smtpd_sender_restrictions=  
   -o smtpd_recipient_restrictions=permit_mynetworks,reject  
   -o smtpd_data_restrictions=reject_unauth_pipelining  
   -o smtpd_end_of_data_restrictions=  
   -o mynetworks=127.0.0.0/8  
   -o smtpd_error_sleep_time=0  
   -o smtpd_soft_error_limit=1001  
   -o smtpd_hard_error_limit=1000  
   -o smtpd_client_connection_count_limit=0  
   -o smtpd_client_connection_rate_limit=0  
   -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks

Starten Sie Postfix neu:

/etc/init.d/postfix restart

10 Dovecot

Dovecot wird POP3- (SSL/TLS), IMAP- (SSL/TLS) und Quota-Unterstützung für den Mailserver bereitstellen.

10.1 Hauptkonfiguration

echo "" > /etc/dovecot/dovecot.conf  
vi /etc/dovecot/dovecot.conf

Der Inhalt sollte so aussehen:

protocols = imap imaps pop3 pop3s 
listen = 0.0.0.0
login_greeting = example.com Mailserver bereit. 
mail_location = maildir:~/Maildir
disable_plaintext_auth = no
ssl_cert_file = /etc/ssl/certs/mail.pem 
ssl_key_file = /etc/ssl/private/mail.key
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.log  

# IMAP-Konfiguration
protocol imap {
    mail_plugins = quota imap_quota
}  

# POP3-Konfiguration
protocol pop3 {
    pop3_uidl_format = %08Xu%08Xv
    mail_plugins = quota
}
             
# LDA-Konfiguration 
protocol lda { 
    postmaster_address = postmaster 
    auth_socket_path = /var/run/dovecot/auth-master
    mail_plugins = quota 
} 
                                         
# LDAP-Authentifizierung
 
auth default {
    mechanisms = plain login
 
    passdb ldap { 
        args = /etc/dovecot/dovecot-ldap.conf 
    }
     
    userdb ldap { 
        args = /etc/dovecot/dovecot-ldap.conf 
    }
     
    socket listen { 
        master { 
            path = /var/run/dovecot/auth-master 
            mode = 0660 
            user = dovecot 
            group = mail 
        }  

        client {
            path = /var/spool/postfix/private/auth
            mode = 0660
            user = postfix
            group = postfix
        }
    }
}

10.2 LDAP-Konfiguration

echo "" > /etc/dovecot/dovecot-ldap.conf  
vi /etc/dovecot/dovecot-ldap.conf

Der Inhalt sollte so aussehen:

hosts = 127.0.0.1
auth_bind = yes
ldap_version = 3
base = dc=example,dc=com
scope = subtree
user_attrs = homeDirectory=home,uidNumber=uid,mailbox=mail,mailuserquota=quota=maildir:storage
user_filter = (&(objectClass=mailAccount)(mail=%u)(mailenable=OK))
pass_attrs = mail=user,userPassword=password
pass_filter = (&(objectClass=mailAccount)(mail=%u)(mailenable=OK))
default_pass_scheme = CRYPT
user_global_gid = mail

10.3 Zustellung

Passen Sie als nächstes die Rechte für die Dovecot-Zustellung an - damit Dovecot die richtige UID und GID verwendet, wenn es Nachrichten in den Maildirs speichert.

dpkg-statoverride --update --add root dovecot 4755 /usr/lib/dovecot/deliver

Starten Sie anschließend Dovecot neu.

/etc/init.d/dovecot restart
Share: X/Twitter LinkedIn

Erhalte neue Beiträge in deinem Posteingang.

Kein Spam. Jederzeit abmelden.