개인적으로, OS X에 내장되어 있는 Postfix mailer를 Postfix Enabler 가지고 켜놓고 사용하고 있다.

그런데, 어느날 갑작스런 메일 서버의 통신량 증가로 system.log를 살펴본 결과, 수상한 발자국들이 찍혀있는 다음과 같은 경고 문구들을 발견하게 되었다.

warning: numeric domain name in resource data of MX record for neticks.com: 127.0.1.51
warning: numeric domain name in resource data of MX record for neticks.com: 127.0.1.51
warning: valid_hostname: empty hostname
warning: malformed domain name in resource data of MX record for angelfire.com: 
warning: numeric domain name in resource data of MX record for staa.com: 69.106.54.69
warning: valid_hostname: empty hostname
warning: malformed domain name in resource data of MX record for angelfire.com: 
warning: numeric domain name in resource data of MX record for staa.com: 69.106.54.69
warning: numeric domain name in resource data of MX record for aolloses.com: 127.0.1.51
warning: valid_hostname: empty hostname
warning: malformed domain name in resource data of MX record for angelfire.com: 
warning: valid_hostname: empty hostname
warning: numeric domain name in resource data of MX record for bioteda.com: 211.156.49.6
warning: numeric domain name in resource data of MX record for jaehnsautobody.com: 127.0.0.10
warning: numeric domain name in resource data of MX record for aolloses.com: 127.0.1.51
warning: valid_hostname: empty hostname
.
.
warning: mail2.remoteit.com[67.102.200.130] offered AUTH option multiple times
warning: mail.airewaves.com[216.24.174.202] offered AUTH option multiple times
warning: mail.visual-impct.com[206.80.23.8] offered AUTH option multiple times
warning: mx.rogersdesign.com[209.60.77.50] offered AUTH option multiple times
warning: mail.marketspacefinancial.com[199.227.43.234] offered AUTH option multiple times
warning: mail.ruralfree.net[209.213.15.65] offered AUTH option multiple times
warning: mail.spec.net[205.167.92.100] offered AUTH option multiple times
warning: imail.ipswitch.com[156.21.1.5] offered AUTH option multiple times
warning: mail.snworks.com[63.75.167.9] offered AUTH option multiple times
warning: mail.komo.com[64.83.205.251] offered AUTH option multiple times
warning: ns2.fourway.net[216.223.165.6] offered AUTH option multiple times
warning: sw1.la-lakers.com[66.226.3.253] offered AUTH option multiple times
warning: mail.pxgp.com[207.201.223.114] offered AUTH option multiple times
warning: mail.pageconcepts.com[204.118.3.168] offered AUTH option multiple times
warning: mail.netscape.everyone.net[216.200.145.10] offered AUTH option multiple times

이런! 😯 수시로 알 수 없는 곳에서 계속 나의 메일 서버를 relay 서버 삼아 쓰레기 전자우편들을 보내려고 시도하고 있는 것이 아닌가? 👿

이것을 계기로 아래는 꼭 살펴보아야 할 Postfix의 보안 관련 필수 설정 항목들을 모아 보았다.

SASLDB를 사용한 SMTP 암호 인증을 사용하지 않는 한 꼭 SSL 암호화 기능을 켜서, 만에 하나 암호가 중간에 가로채어지는 일을 방지할 것.

– /etc/postfix/main.cf:
# 인가된 네트워크에서만 접속을 허용.
smtpd_client_restrictions = permit_mynetworks, reject

# 자신의 hostname을 모르는 메일 시스템한테는 얘기를 안함.
# Postfix 버전이 < 2.3일 경우, reject_unknown_hostname를 지정.
smtpd_helo_restrictions = reject_unknown_helo_hostname

# 존재하지 않는 도메인에서는 전자우편을 받지 않음.
smtpd_sender_restrictions = reject_unknown_sender_domain

# 로컬 클라이언트들은 목적지의 지정이 자유로우나, 그 이외에는 차단.

smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination

# pipelining 명령을 못 알아드는 엉성한 클라이언트들은 차단.
smtpd_data_restrictions = reject_unauth_pipelining

# relay_domains_reject_code 변수는 SMTP 서버가 메일 전달 지침을 무시하려는
# 클라이언트들에게 어떻게 응답할 것인지를 지정함.
# 이것의 변수는 RFC 821를 따름. 기본값은 554: Transaction failed.
# 550: no access
relay_domains_reject_code = 550

# SMTP 클라이언트들은 SMTP 세션을 시작하기 전에
# 먼저 자신의 정체를 밝히도록 함.
smtpd_helo_required = yes

# 메일 전달 목적지가 Postfix에 의해 인가된 곳이더라도,
# 인가되지 않은 곳으로부터의 어떠한 메일 전달도 허용하지 않도록 함.
# 기본적으로 설정되어 있는 값이지만, 추가해 놓는다고 해가 될 것은 없다.
allow_untrusted_routing = no

Open Relay Database 같은 곳에 자신의 메일 서버가 스펨 메일 서버로 등록되지 않으려면, 주의가 필요하다.

– 추가 참고 글

관련된 주제의 글

댓글을 남겨 주세요