[홈서버] postfix smtp 메일 서버 구축
POSTFIX 구축 시 letsencrypt 인증기관에서 발급받은 인증서를 사용할 것이다. 앞서 아래 콘텐츠를 먼저 열람하길 바란다.
[홈서버] letsencrypt 인증서 발급 받기
메일 서버, 웹서버 운영을 보안 프로토콜로 사용하기 위해서는 허가받은 인증기관의 인증서를 사용하는 것이 좋다. 이런 인증기관의 인증서는 대부분 유료고 개인이 홈서버를 위해 발급받기는
malchooni.name
메일 서버는 발송하는 부분과 사용자가 수신받는 부분으로 나눌 수 있다. 메일을 발송하는 SMTP 서버 구축을 위해 POSTFIX를 사용하기로 한다. 사이트에서 POSTFIX는 구글의 'Wietse Venema'라는 개발자가 개발했다고 한다.
The Postfix Home Page
The Postfix Home Page All programmers are optimists -- Frederick P. Brooks, Jr. First of all, thank you for your interest in the Postfix project. What is Postfix? It is Wietse Venema's mail server that started life at IBM research as an alternative to the
www.postfix.org
OS는 우분투 20.04 버전에서 작업을 하였다. 설치는 간단한 명령어로 가능하다.
> apt-get install postfix
root@mail:/# apt-get install postfix . . Postfix Configuration --------------------- Please select the mail server configuration type that best meets your needs. No configuration: Should be chosen to leave the current configuration unchanged. Internet site: Mail is sent and received directly using SMTP. Internet with smarthost: Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost. Satellite system: All mail is sent to another machine, called a 'smarthost', for delivery. Local only: The only delivered mail is the mail for local users. There is no network. 1. No configuration 2. Internet Site 3. Internet with smarthost 4. Satellite system 5. Local only General type of mail configuration: 1 Unpacking postfix (3.4.13-0ubuntu1) ... |
Postfix 설치 시 설치 유형을 물어본다, No configuration을 선택 후 세부적인 설정은 환경설정 파일을 변경하여 진행할 예정이다.
Postfix의 설정 파일은 /etc/postfix 디렉터리의 main.cf 와 master.cf로 구성되어있다. 이 파일들에 대한 권한은 루트에게 있어야 한다. 환경 설정 변경 후 적용은 재시작 또는 "postfix reload" 명령어를 활용한다.
설정에 앞서 main.cf 파라미터 정보는 공식 사이트에서 확인할 수 있다.
보통 /etc/postfix 디렉터리로 이동 후 프로토타입의 설정 파일을 main.cf로 복사 한다. 그러나 필자는 파라미터 정보를 확인 후 새로운 파일로 생성하겠다.
root@mail:/etc/postfix# vi main.cf |
# 도메인 이름 (기본값 >> postconf -d | grep mydomain ) mydomain = yalsooni.name # hotname (기본값 >> postconf -d | grep mydomain ) myhostname = mail.yalsooni.name # 배달되는 도메인 목록 mydestination = $myhostname, $mydomain, localhost # 배달되는 도메인 이름 (local) myorigin = $mydomain # smtp 접속 인사말 smtpd_banner = $myhostname ESMTP $mail_name # 알림 설정 제거 biff = no # 메일 크기 제한 (기본값 51200000) mailbox_size_limit = 0 # 주소 확장 구분 기호 recipient_delimiter = + # 사용자 홈 디렉터리 설정 for qmail-style delivery home_mailbox = Maildir/ # 이전 버전과 호환을 위한 설정 compatibility_level=2 # 전달 별칭 데이터베이스 설정 alias_maps = hash:/etc/aliases # SASL 인증 활성화 smtpd_sasl_auth_enable = yes # 비표준 지원 여부 (RFC 4954) broken_sasl_auth_clients = yes # Dovecot SASL 사용 smtpd_sasl_type = dovecot # UNIX Domain smtpd_sasl_path = private/auth # 인증 메커니즘 smtpd_sasl_security_options = noanonymous smtpd_sasl_tls_security_options = noanonymous smtpd_tls_auth_only = no smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination # 로그인 이름에 도메인 추가 e.g. "john" instead of "john@example.com" smtpd_sasl_local_domain = $mydomain # smtp client tls level smtp_tls_security_level = may # smtp server tls level smtpd_tls_security_level = may # CA인증서 smtpd_tls_CAfile = /etc/letsencrypt/live/yalsooni.name/fullchain.pem # 공개키 smtpd_tls_cert_file = /etc/letsencrypt/live/yalsooni.name/cert.pem # 개인키 smtpd_tls_key_file = /etc/letsencrypt/live/yalsooni.name/privkey.pem |
위의 설정 파일은 Dovecot (pop3d, imapd)를 고려한 설정이다. 설정 복사 시 도메인, 인증서 등 필요 설정을 자신에 맞게 변경하면 된다. 변경해야 할 부분은 파란색으로 표시했다.
이후 master.cf 설정 파일을 열어 아래와 같이 주석과 설정 값을 변경한다.
root@mail:/etc/postfix# vi master.cf |
위의 스크린숏처럼 빨간 네모 부분을 수정한다.
POSTFIX 재시작에 앞서 /etc/aliases 파일을 빌드한다. 방법은 두 가지다.
"run "postalias /etc/aliases" (or wherever your system stores the mail alias file), or simply run "newaliases" to build the necessary DBM or DB file." |
postalias /etc/aliases 명령어를 실행하거나 newaliases 명령어를 실행하면 된다.
root@mail:/etc/postfix# postalias /etc/aliases |
POSTFIX를 재시작한다.
root@mail:/etc/postfix# /etc/init.d/postfix stop * Stopping Postfix Mail Transport Agent postfix [ OK ] root@mail:/etc/postfix# /etc/init.d/postfix start * Starting Postfix Mail Transport Agent postfix [ OK ] root@mail:/etc/postfix# |
Dovecot을 활용한 수신 메일 서버를 구축하고 OS 계정을 추가하여 메일 테스트를 진행해 보겠다.
[홈서버] dovecot pop3 imap 메일 서버 구축
[홈서버] letsencrypt 인증서 발급 받기 메일 서버, 웹서버 운영을 보안 프로토콜로 사용하기 위해서는 허가받은 인증기관의 인증서를 사용하는 것이 좋다. 이런 인증기관의 인증서는 대부분 유료��
malchooni.name