서버 설정 · 2 min read · Feb 06, 2026

완벽한 서버 - Gentoo 2007.0 - 5페이지

12 Postfix with SMTP-AUTH and TLS

먼저 USE 플래그를 적절하게 설정합니다.

echo "mail-mta/postfix sasl" >> /etc/portage/package.use   
echo "dev-libs/cyrus-sasl authdaemond urandom" >> /etc/portage/package.use   
echo "net-mail/courier-imap fam" >> /etc/portage/package.use

그 다음 실제로 설치합니다.

emerge --ask --verbose postfix courier-imap procmail

courier-imap은 이러한 USE 플래그로 postfix의 종속성으로 포함되지만, 명령줄에 포함하면 우리가 특별히 원했던 패키지 목록인 world 파일에 추가됩니다.

/etc/mail/aliases를 편집하여 root의 별칭을 관리자 사용자로 설정합니다. Gentoo에는 완료하고 주석을 제거할 수 있는 주석 처리된 줄이 있습니다.

root: administrator
newaliases

이제 postfix 자체를 구성하고자 합니다. Gentoo에서는 기본적으로 chroot에서 실행되지 않으며, 그렇게 만드는 것은 현재 이 HowTo의 범위를 벗어납니다.

우리는 Postfix를 일반 Maildir 작업을 위해 설정합니다. 이는 ISPConfig를 위해 특별히 설정하는 것이 아니며, ISPConfig를 위해 필요한 변경 사항은 18단계에 나와 있습니다.

postconf -e "myhostname = $(hostname -f)"   
postconf -e 'mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain'   
postconf -e 'mynetworks = 127.0.0.0/8'   
postconf -e 'recipient_delimiter = +'   
postconf -e 'mailbox_size_limit = 0'   
postconf -e 'inet_interfaces = all'   
postconf -e 'inet_protocols = all'   
postconf -e 'home_mailbox = Maildir/'

이제 sasl을 설정합니다.

postconf -e 'smtpd_sasl_local_domain ='   
postconf -e 'smtpd_sasl_auth_enable = yes'   
postconf -e 'smtpd_sasl_security_options = noanonymous'   
postconf -e 'broken_sasl_auth_clients = yes'   
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'   
echo 'pwcheck_method: saslauthd' >> /etc/sasl2/smtpd.conf   
echo 'mech_list: plain login' >> /etc/sasl2/smtpd.conf

이제 postfix를 위한 ssl 인증서를 생성합니다.

cd /etc/ssl   
vi openssl.cnf

도메인에 대한 기본값을 변경합니다. 기본적으로 이는 새 인증서 요청을 생성할 때 나타나는 기본값이므로 이 단계를 생략하고 일반적인 기본값에 직면할 수 있습니다. 최소한 두 번 입력해야 하므로 아마도 가치가 있을 것입니다.

countryName_default
stateOrProvinceName_default
localityName_default
0.organizationName_default
emailAddress_default

그리고 인증서를 생성합니다.

cd misc   
./CA.pl -newreq-nodes   
./CA.pl -newca   
./CA.pl -sign   
cp newcert.pem newkey.pem demoCA/cacert.pem /etc/postfix/

그리고 그것으로 postfix를 구성합니다.

postconf -e 'smtpd_tls_auth_only = no'   
postconf -e 'smtp_use_tls = yes'   
postconf -e 'smtpd_use_tls = yes'   
postconf -e 'smtp_tls_note_starttls_offer = yes'   
postconf -e 'smtpd_tls_key_file = /etc/postfix/newkey.pem'   
postconf -e 'smtpd_tls_cert_file = /etc/postfix/newcert.pem'   
postconf -e 'smtpd_tls_CAfile = /etc/postfix/cacert.pem'   
postconf -e 'smtpd_tls_loglevel = 1'   
postconf -e 'smtpd_tls_received_header = yes'   
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'   
postconf -e 'tls_random_source = dev:/dev/urandom'

postfix와 saslauthd를 시작하고 부팅 시 시작하도록 설정합니다.

/etc/init.d/saslauthd start   
rc-update add saslauthd default   
/etc/init.d/postfix start   
rc-update add postfix default

SMTP-AUTH와 TLS가 제대로 작동하는지 확인하려면 다음 명령을 실행합니다:

telnet localhost 25

Postfix 메일 서버에 연결한 후 다음을 입력합니다:

ehlo localhost

다음과 같은 줄이 보이면

250-STARTTLS

250-AUTH LOGIN PLAIN

모든 것이 정상입니다.

내 시스템의 출력은 다음과 같습니다:

server1 misc # telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
quit

시스템의 셸로 돌아가려면 입력합니다.

13 Courier-IMAP/Courier-POP3

우리가 필요한 courier-imap 소프트웨어는 postfix 설치 시 종속성으로 모두 설치되었습니다. 이제 설정을 마무리하면 됩니다.

cd /etc/courier-imap   
vi pop3d.cnf   
vi imapd.cnf

C, ST, L, CN 및 이메일 매개변수를 서버에 맞게 변경합니다. 특히 CN 필드가 메일 클라이언트가 메일 서버에 연결하는 데 사용할 호스트 이름인지 확인합니다. 그런 다음,

mkpop3dcert   
mkimapdcert

이제 courier-imap의 다양한 서비스를 시작하고 부팅 시 시작하도록 구성할 수 있습니다.

/etc/init.d/courier-imapd start   
/etc/init.d/courier-imapd-ssl start   
/etc/init.d/courier-pop3d start   
/etc/init.d/courier-pop3d-ssl start   
rc-update add courier-imapd default   
rc-update add courier-imapd-ssl default   
rc-update add courier-pop3d default   
rc-update add courier-pop3d-ssl default
Share: X/Twitter LinkedIn

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

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