Sendmail에서 TCP 587번 포트를 사용하는 방법은 무엇인가요?
💡 요약 정리
- 유동 IP 환경에서는 25번 포트가 차단되어 있어 587번 포트를 사용해야 합니다.
- sendmail.mc 파일을 수정하여 587번 포트를 열고 설정을 적용해야 합니다.
- 수정 이후 sendmail을 재시작하여 변경 사항을 반영합니다.
- 작업 완료 후 netstat 명령어를 통해 587 포트 열림 여부를 확인할 수 있습니 다.
1. 설치 환경
- CentOS 5.8 x86 (64bit)
2. 587번 포트 사용 이유
- 정부의 스팸메일 근절 정책에 따라 유동 IP에서는 25번 포트를 제한하고 있습니다.
- 따라서 유동 IP를 사용하고 있다면 기존의 25번 포트 대신 587번 포트를 이용해서 메일을 보내야 합니다.
3. 587번 포트 열기
/etc/mail/sendmail.mc파일의 약 123번째 라인에서 아래와 같이 수정하여 주석을 해제해야 합니다.
[root@localhost /root]$ vim /etc/mail/sendmail.mc
수정 전후 예시는 아래와 같습니다.
111 dnl #
112 dnl # The following causes sendmail to only listen on the IPv4 loopback address
113 dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
114 dnl # address restriction to accept email from the internet or intranet.
115 dnl #
116 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
117 dnl #
118 dnl # The following causes sendmail to additionally listen to port 587 for
119 dnl # mail from MUAs that authenticate. Roaming users who can't reach their
120 dnl # preferred sendmail daemon due to port 25 being blocked or redirected find
121 dnl # this useful.
122 dnl #
123 DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl <--- 주석 해제!
124 dnl #
125 dnl # The following causes sendmail to additionally listen to port 465, but
126 dnl # starting immediately in TLS mode upon connecting. Port 25 or 587 followed
127 dnl # by STARTTLS is preferred, but roaming clients using Outlook Express can't
128 dnl # do STARTTLS on ports other than 25. Mozilla Mail can ONLY use STARTTLS
129 dnl # and doesn't support the deprecated smtps; Evolution <1.1.1 uses smtps
130 dnl # when SSL is enabled-- STARTTLS support is available in version 1.1.1.
131 dnl #
132 dnl # For this to work your OpenSSL certificates must be configured
4. sendmail.cf 파일에 변경사항 적용
- 변경된
.mc파일을.cf파일로 변환합니다.
[root@localhost /etc/mail]$ m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
5. Sendmail 재시작
- Sendmail을 재시작하여 변경 사항을 적용합니다.
[root@localhost /etc/mail]$ /etc/rc.d/init.d/sendmail restart
sm-client를 종료 중: [ OK ]
sendmail 를 종료 중: [ OK ]
sendmail (을)를 시작합니다: [ OK ]
sm-client를 시작합니다: [ OK ]
6. 포트 열림 확인
netstat명령어를 통해 587번 포트가 정상적으로 열려 있는지 확인합니다.
[root@localhost /root]$ netstat -nlpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 364/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 364/dovecot
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 11173/sendmail
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 364/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 364/dovecot
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7377/httpd
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1766/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1730/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 11173/sendmail
[root@localhost /etc/mail]#