서버 구성 · 4 min read · Oct 07, 2025

Debian Etch에서 Mandriva 디렉토리 서버 - 페이지 3

8 SASL 구성

Postfix는 SASL을 사용하여 LDAP 서버에 대해 사용자를 인증합니다.

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

기본 설정을 조정합니다.

vi /etc/default/saslauthd

다음과 같이 보여야 합니다:

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

다음과 같이 보여야 합니다:

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

다음과 같이 보여야 합니다:

pwcheck_method: saslauthd
mech_list: plain login

Postfix를 SASL 그룹에 추가합니다…

adduser postfix sasl

… 그리고 SASL을 재시작합니다.

/etc/init.d/saslauthd restart

9 Postfix 구성

9.1 예제 구성

이 설정을 위해 가상 도메인 없이 구성을 선택했습니다 - 아마도 가까운 미래에 가상 도메인 설정을 위한 필요한 단계를 추가할 것입니다. 먼저 예제 구성 파일을 postfix 디렉토리로 복사합니다. 이는 다음 구성의 기반입니다.

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

9.2 주요 구성

먼저 주요 구성 파일을 조정합니다.

vi /etc/postfix/main.cf

파일을 귀하의 도메인에 맞게 편집하고 추가로 몇 가지 제한 및 인증 설정을 추가합니다 - 내용은 다음과 같아야 합니다:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no  

# appending .domain is the MUA's job.
append_dot_mydomain = yes
append_at_myorigin = yes  

# Uncomment the next line to generate "delayed mail" warnings
#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  

# Use Maildir
home_mailbox = Maildir/  

# Wait until the RCPT TO command before evaluating restrictions 
smtpd_delay_reject = yes  

# Basics Restrictions 
smtpd_helo_required = yes 
strict_rfc821_envelopes = yes  

# Requirements for the connecting 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  

# Requirements for the HELO statement 
smtpd_helo_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_hostname, 
   reject_invalid_hostname, 
   permit  

# Requirements for the sender address 
smtpd_sender_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_sender, 
   reject_unknown_sender_domain, 
   permit  

# Requirement for the recipient address 
smtpd_recipient_restrictions = 
   permit_mynetworks, 
   permit_sasl_authenticated, 
   reject_non_fqdn_recipient, 
   reject_unknown_recipient_domain, 
   reject_unauth_destination, 
   permit  

# Enable SASL authentication for the smtpd daemon 
smtpd_sasl_auth_enable = yes 
smtpd_sasl_type = dovecot 
smtpd_sasl_path = private/auth  

# Fix for outlook
broken_sasl_auth_clients = yes  

# Reject anonymous connections 
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 별칭 구성

이제 별칭 구성을 편집해야 합니다.

vi /etc/postfix/ldap-aliases.cf

파일을 귀하의 도메인에 맞게 편집합니다 - 다음과 같아야 합니다:

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 마스터 구성

마스터 구성은 postfix 구성의 마지막 부분입니다.

vi /etc/postfix/master.cf

다음 줄을 추가합니다:

# 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 to 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 from 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

Postfix를 재시작합니다:

/etc/init.d/postfix restart

10 Dovecot

Dovecot는 POP3(SSL/TLS), IMAP(SSL/TLS) 및 쿼터 지원을 메일 서버에 제공합니다.

10.1 주요 구성

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

내용은 다음과 같아야 합니다:

protocols = imap imaps pop3 pop3s 
listen = 0.0.0.0
login_greeting = example.com mailserver ready. 
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 구성
protocol imap {
    mail_plugins = quota imap_quota
}  

# POP3 구성
protocol pop3 {
    pop3_uidl_format = %08Xu%08Xv
    mail_plugins = quota
}
             
# LDA 구성 
protocol lda { 
    postmaster_address = postmaster 
    auth_socket_path = /var/run/dovecot/auth-master
    mail_plugins = quota 
} 
                                         
# LDAP 인증
 
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 구성

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

내용은 다음과 같아야 합니다:

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 배달

다음으로 dovecot 배달의 권한을 조정합니다 - 따라서 dovecot는 메일 디렉토리에 메시지를 저장할 때 올바른 uid 및 gid를 사용합니다.

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

그 후 Dovecot을 재시작합니다.

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

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.