Old stories/Unix&Linux

CentOS - 메일 서버 구성을 위한 Sendmail 설치 및 설정

드카니 2010. 7. 23. 15:58

1. sendmail RPM 설치 여부 확인
# yum list installed | grep sendmail or yum list sendmail

존재하지 않을 경우 설치
# yum install sendmail (sendmail & sendmail-cf 설치 확인)

2. 메일 서버로 설정하기 위해 sendmail.mc를 수정 후 sendmail.cf를 재 생성해 준다.
*. smtp 인증 기능 활성화를 위해 다음 두 줄의 dnl 부분 제거. (smtp 인증 기능을 사용하지 않을 경우 제외)
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
                                                               ↓
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

*. senmail은 기본적으로 로컬(서버)에서 보내는 메일만 relay(전달)하지만, 메일서버로 사용하기 위해서는 이 설정을 제거해야됨. 설정 제거를 위해 앞 부분에 dnl 추가 또는 해당 라인 삭제 or IP 변경 (127.0.0.1 -> 0.0.0.0)
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
                                         ↓
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

위의 내용 수정 후 다음 명령으로 sendmail.cf 재 생성
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

3. Relay 설정 및 메일 서버 네임 설정
access 파일에 Replay 가능하게 할 내역들을 추가한 후 db를 생성. relay 및 스팸 처리로 내용 변경 시 마다 db 재 생성해야 됨.
# makemap hash /etc/mail/access.db < /etc/mail/access
호출될 메일 서버 네임은 다음의 파일에 추가해 준다.
# vi /etc/mail/local-host-names
서버 네임 alias 모두 추가

4. sendmail 데몬 구동
# service sendmail start
or
# /etc/init.d/sendmail start

*. smtp 인증 기능은 Relay 설정 없이 계정만으로 외부에서 메일 서버를 이용하게 하는 방법이다. 기본적으로 Relay로 가능하니 필요없는 기능이나, 유동 IP대역에서 메일 서버를 활용해야 하는 경우 필요하다. (관련 설정 참조 : 클릭.)
*. smtp 인증 설정 만으로 실제 인증이 되진 않으며, cyrus-sasl 패키지가 설치되어 있는 환경하에 아래와 같은 작업을 추가해야 한다.
 - /etc/sasl2/sendmail.conf 생성
   # vi /etc/sasl2/sendmail.conf
   pwcheck_method: shadow
 - saslauthd 데몬 활성화
   # service saslauthd start
   # chkconfig saslauthd on (부팅 시 자동 실행)
*. SELinux가 활성화되어 있는 상태에서는 setup or system-config-securitylevel 명령을 이용하거나, iptable 설정을 직접 변경하여 외부 접속을 허용해줘야 한다.
*. SELinux가 비활성화되어 있는 경우, /etc/hosts.allow에 다음의 내용을 추가해줘야 한다.
# vi /etc/hosts.allow
sendmail : ALL : allow (보안 정책에 맞게 ALL을 수정해주길..)


반응형