초보자를 위한 Exim4 설정하기

이강우 2015/07/27 10:24

데비안 설치시 기본적으로 설치되는 Exim4 MTA를 초보자도 완벽하게 설치 할수 있도록 하는것이 이 문서의 목적이다.
이 문서는 아래와 같은 조건을 기본으로 한다.

  • 해당 서버가 메일서버로 동작한다.
  • 계정은 시스템 계정을 기본으로 한다.(가상유저 지원안함)
  • POP3서비스를 제공한다.
  • 기본적으로 모든 릴레이는 막혀 있으며 SMTP인증을 통하여 메일을 발송한다.
  • 본 문서는 Debian Linux를 기준으로 설명하고 있다.
  • 문서에 나와있는 호스트의 이름은 mail.foobar.com 이다.
  • 이 호스트는 domain.net의 메일도 수신하고 있다.

우선 아래의 패키지들을 설치하도록 한다.

  • exim4
  • qpopper
  • sasl2-bin
$ apt-get install exim4 qpopper sasl2-bin

/etc/exim4 디렉토리에 들어가면 아래의 파일이 들어있다.

$ ls exim4.conf.template passwd.client update-exim4.conf.conf

우선 update-exim4.conf.conf 파일을 수정한다.

# /etc/exim4/update-exim4.conf.conf
#
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
# yourself or use 'dpkg-reconfigure exim4-config'
#
# Please note that this is _not_ a dpkg-conffile and that automatic changes
# to this file might happen. The code handling this will honor your local
# changes, so this is usually fine, but will break local schemes that mess
# around with multiple versions of the file.
#
# update-exim4.conf uses this file to determine variable values to replace
# the DEBCONFsomethingDEBCONF strings in the configuration template files.
#
# Most settings found in here do have corresponding questions in the
# Debconf configuration, but not all of them.
#
# This is a Debian specific file
dc_eximconfig_configtype='internet'
dc_other_hostnames='foobar.com:domain.net' # FQDN 이부분에 메일도메인을 적어준다. 여러개의 도메인을 운영중이라면 : 로 구분한다.
dc_local_interfaces='' # 이부분은 접속허용가능호스트를 적어준다. 기본적으로 모든 메일을 받아야 하므로 비워둔다.
dc_readhost=''
dc_relay_domains='' # 다른곳으로 릴레이 시킬 도메인을 적는부분이다. 비워둔다.
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'

자 위와같이 수정한후 아래의 명령을 실행하면 exim config파일이 자동으로 생성된다.

$ update-exim4.conf -d /etc/exim4 -o /etc/exim4/exim4.conf
$ ls /etc/exim4
./  ../  conf.d/  exim4.conf  exim4.conf.template  passwd.client  update-exim4.conf.conf

여기까지가 기본적인 Exim4의 설정단계이다. 이렇게 하면 기본적으로 메일을 받는것은 문제 없이 될것이다.
아울러 POP3또한 qpopper패키지를 설치하게 되면 별다른 설정없이 ?POP3서비스를 이용할수 있다.

이제 메일을 보내는 작업을 하게 될것이다.
일반적으로 모든 메일서버는 릴레이를 제한하여야 하는데 그 이유는 무분별한 스팸메일을 막기 위해서 이다.
그러나 가끔 개념이 없는 관리자는 이런것을 무시하고 메일서버를 대충 설치하는 경우 해당 서버가 스패머들에의해
엄청난양의 스팸메일을 뿌리거나 네트워크 대역폭을 낭비하는 경우가 생긴다.
따라서 서버의 릴레이를 제한하고 인증된 사용자만이 메일을 보낼수 있도록 셋팅하도록 한다.
맨처음에 설치한 패키지중 sasl2-bin 패키지가 이러한 SMTP인증을 해주는 데몬 패키지 이다.
그 첫번째 단계로 우선 Exim4의 설정을 SMTP인증으로 변경하는 작업을 해보도록 하자
/etc/exim4/exim4.conf.template 파일을 연다.

$ vi /etc/exim4/exim4.conf.template

위의 화일을 열어 아래와같이 주석처리된 부분을 제거한다.

.......상단생략.......
# Authenticate against local passwords using sasl2-bin
# Requires exim_uid to be a member of sasl group, see README.SMTP-AUTH
plain_saslauthd_server:
driver = plaintext
public_name = PLAIN
server_condition = ${if saslauthd{{$2}{$3}}{1}{0}}
server_set_id = $2
server_prompts = :
#   .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
#   server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
#   .endif
#
login_saslauthd_server:
driver = plaintext
public_name = LOGIN
server_prompts = "Username:: : Password::"
# don't send system passwords over unencrypted connections
#   server_advertise_condition = ${if eq{$tls_cipher}{}{0}{1}}
server_condition = ${if saslauthd{{$1}{$2}}{1}{0}}
server_set_id = $1
#   .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
#   server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
#   .endif
#
## 이하 모든 아래내용은 주석처리 하도록 한다. ##

위와같이 exim4.conf.template화일을 수정한후

$ update-exim4.conf -d /etc/exim4 -o /etc/exim4/exim4.conf

명령을 다시 해주어 exim4.conf화일을 재생성한다.
그리고 /etc/group 파일을 열어 Debian-exim유저를 sasl그룹에 포함시켜준다.

root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:hal
floppy:x:25:hal
tape:x:26:
sudo:x:27:
audio:x:29:
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:Debian-exim           # 여기에 추가시켜준다.
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
crontab:x:101:
Debian-exim:x:102:
ssh:x:103:
messagebus:x:104:
dirmngr:x:105:
hal:x:106:
camera:x:107:
scanner:x:108:
saned:x:109:
gdm:x:110:

sasl 데몬을 기동하기 위해 아래의 파일을 수정한다.

$ vi /etc/default/saslauthd
# This needs to be uncommented before saslauthd will be run automatically
# START=yes
# You must specify the authentication mechanisms you wish to use.
# This defaults to "pam" for PAM support, but may also include
# "shadow" or "sasldb", like this:
# MECHANISMS="pam shadow"
START="yes"  # 데몬을 가동하기 위해 추가한다.
MECHANISMS="pam shadow"
# 기본적인 password방식은 shadow이므로 shadow만 있어도 상관 없다.

이제 exim4와 sasl데몬을 재시작 하도록 한다.

$ /etc/init.d/saslauthd restart
Stopping SASL Authentication Daemon: saslauthd.
Starting SASL Authentication Daemon: saslauthd.
$ /etc/init.d/exim4 restart
Restarting MTA: exim4.

마지막으로 모든 설정이 제대로 되었는지 확인하기 위해 메일이 잘 오가는지 테스트 해보도록 한다.
아울러 릴레이가 제대로 막혀 있는지 확인또한 철저히 하여 불필요한 스팸메일을 발송하지 못하도록 한다.
릴레이 테스트
릴레이 테스트는 아래의 페이지에서 간단하게 할 수 있다.
http://people.kldp.org/~eunjea/relay-test.php

이상으로 Exim4의 가장 기본적인 설정을 마무리하도록 한다.
기타 문서에 대한 교정이나 내용의 문의사항은 아래로 연락바랍니다.
Email & MSN : coolseed@hotmail.com

로그인하면 댓글을 남길 수 있습니다.
  • 초보자를_위한_exim4_설정하기.txt
  • 마지막으로 수정됨: 2015/08/18 01:15
  • 저자 koov