리눅스

Total 331
Today 0
profile_image
슈퍼아이피
13-09-29 11:37 0개 18회
설치문서
CentOS 6.x 에서 sendmail+dovecot+saslauthd
Centos 6.x 부터는 Postfix 가 기본이다.
 
오랜만에 기억을 되살려 sendmail로 smtp+pop3+imap+webmail을 구성해보았다.
 
<환경 설치>
1. 린구스 콘솔 언어설정
 /etc/sysconfig/i18n 파일 수정
---------------------------------------------------------
 LANG="en_US.UTF-8"
 SYSFONT="latarcyrheb-sun16"
---------------------------------------------------------
LANG="en_US"
SUPPORTED="en_US.UTF-8:en_en:ko_KR.eucKR:ko_KR:ko"
SYSFONT="latarcyrheb-sun16"
SYSFONTACM="iso01"
LC_CTYPE="ko_KR" 
---------------------------------------------------------
2. DNS 주소 셋팅
또한, 원할한 yum 업데이트나 네임서버 경로설정을 위해서 다음 파일을 열어 삽입한다.
vi /etc/resolv.conf
search 164.124.101.2
nameserver 168.126.63.1
nameserver 168.126.63.2
3. 타임싱크 설정
vi /etc/crontab 을 열어,
0,5,10,15,20,25,30,35,40,45,50,55 * * * * root rdate -s zero.bora.net 삽입! 다음, 리부팅한다.
4. 아래 명령으로 커널을 최신 안정화버전으로 업데이트 하자.
yum update -y kernel*
커널이 정상적으로 업데이트 됐는지 확인시엔 uname -r 명령을 사용하여 커널버전을 확인하면 된다.

5. DOS ATTACK 공격 차단 설정
vi /etc/rc.d/rc.local
아래의 명령문을 입력하여 부팅시 마다 실행
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "2" > /proc/sys/net/ipv4/tcp_retries1
echo "8192" > /proc/sys/net/ipv4/tcp_max_syn_backlog
 
Postfix 삭제
 
# yum remove postfix*
 
Sendmail 설치
# yum install -y sendmail sendmail-cf sendmail-devel
# yum install -y saslauthd     -> 샌드메일에서 사용자 인증 메일발송을 사용하기 위한 데몬
 
도메인 추가
vi /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here
aaa.com
 
접근 권한 설정
vi /etc/mail/access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
aaa.com                     RELAY
 
접근 권한 설정 적용
makemap hash < /etc/mail/access < /etc/mail/access --> 이 명령을 실행해야 access db파일을 해시적용할 수 있다.
makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
makemap hash /etc/mail/domaintable < /etc/mail/domaintable
makemap hash /etc/mail/mailertable < /etc/mail/mailertable
 
sendmail.cf 생성하기>
1. 만약을 위하여 /etc/mail/sendmail.cf를 /etc/mail/sendmail.cf.old 로 변경한 후 시작하자.
 mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
2. sendmail.mc 파일을 열어 아랫부분들을 수정하자.
vi /etc/mail/sendmail.mc

(auth-smtp 설정부분)
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
위 부분의 항목에서 위와 같이 앞의 dnl을 삭제하자

(mail 릴레이 설정부분)
#O DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl  을,
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl  으로 수정     (주석제거 및 Addr 부분 수정)
3. 이제 sendmail.cf 파일을 생성시키자.
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
sendmail.cf에서 SMTP Daemon 옵션을 수정한다.
vi /etc/mail/sendmail.cf
--------------------------------------------------------
# SMTP daemon options
(수정 전)O DaemonPortOptions=Port=smtp, Addr=0.0.0.0, Name=MTA
(수정 후)O DaemonPortOptions=Port=smtp,  Name=MTA
메일발송 용량/ 수신용량 제한
# maximum message size
(수정 전)#O MaxMessageSize=0   
(수정 후)O MaxMessageSize=5024000     -> 으로 수정(5M로 제한)
##################################################
###   Local and Program Mailer specification   ###
##################################################
위 부분에서,,
Mlocal,         P=/usr/bin/procmail, F=lsDFMAw5:/|@qSPfhn9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
                T=DNS/RFC822/X-Unix,
                A=procmail -t -Y -a $h -d $u
위 항목에서,,
T=DNS/RFC822/X-Unix 앞 부분에 ,M=5024000, (5M)부분을 추가
위 설정은 용량 제한시만 사용한다.
#service sendmail start
#chkconfig --level 2345 sendmail on
#service saslauthd start
#chkconfig --leve 2345 saslauthd on
<Dovecot 설치 : POP3, IMAP서버>
1. dovecot(POP3:tcp110, IMAP:tcp143) 설치
yum install -y dovecot*     => 의존성문제로 mysql도 같이 install된다.
 
# vi /etc/dovecot/dovecot.conf
## Dovecot configuration file
# If you're in a hurry, see http://wiki.dovecot.org/QuickConfiguration
# "doveconf -n" command gives a clean output of the changed settings. Use it
# instead of copy&pasting files when posting to the Dovecot mailing list.
# '#' character and everything after it is treated as comments. Extra spaces
# and tabs are ignored. If you want to use either of these explicitly, put the
# value inside quotes, eg.: key = "# char and trailing whitespace  "
# Default values are shown for each setting, it's not required to uncomment
# those. These are exceptions to this though: No sections (e.g. namespace {})
# or plugin settings are added by default, they're listed only as examples.
# Paths are also just examples with the real defaults being based on configure
# options. The paths listed here are for configure --prefix=/usr
# --sysconfdir=/etc --localstatedir=/var
# Protocols we want to be serving.
protocols = imap pop3 lmtp
# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
listen = *, ::
위 색깔 칠해진부분만 수정한다.
vi /etc/dovecot/conf.d/10-auth.conf
(수정전)#disable_plainttext_auth = yes
(수정후)disable_plaintext_auth = no
 
vi /etc/dovecot/conf.d/10-mail.conf
#mail location=
#mail location = mbox:~/mail:INBOX=/var/mail/%u
 
#service dovecot start
#chkconfig --level 2345 dovecot on
 
테스트
smtp 테스트
telnet mail.dc119.com 25
Trying 222.122.60.65...
Connected to mail.dc119.com.
Escape character is '^]'.
220 mail.dc119.com ESMTP Sendmail 8.14.4/8.14.4; Sun, 29 Sep 2013 11:30:11 +0900
helo mail.dc119.com
250 mail.dc119.com Hello [222.122.60.65], pleased to meet you
ehlo mail.dc119.com
250-mail.dc119.com Hello [222.122.60.65], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
250-DELIVERBY
250 HELP
mail from:jinhan2@dc119.com
250 2.1.0 jinhan2@dc119.com... Sender ok
rcpt to:jinhan2@superbabo.com
250 2.1.5 jinhan2@superbabo.com... Recipient ok
data
354 Enter mail, end with "." on a line by itself
mail test
mail test
mail test
.
250 2.0.0 r8T2UBP3002919 Message accepted for delivery
테스트완료
 
pop3 테스트
telnet localhost 110
user 유저계정
pass 암호
List
retr 1
quit
 
imap 테스트
telnet localhost 143
a login 유저계정 암호
b select inbox
c list "" *
e logout
 
list "" * 는 inbox 이외의 다른 메일 박스를 조회한다.
 
 
오래 걸리네.  여기까지 하면 smtp+pop3+imap 까지 설치 완료입니다.
 
중간 중간 빠진 것이 있을 수 있지만 해결할수 있으리라 봅니다.
 
로그는 /var/log/maillog에 쌓입니다.. 참고하시면서 메일 확인을 해주시기 바랍니다.
 
 
 
 

댓글목록

등록된 댓글이 없습니다.