메일 서버 · 3 min read · Nov 28, 2025

Postfix with dkfilter (DomainKeys Implementation)

Postfix with dkfilter (DomainKeys Implementation)

Author: Sohail Riaz

DomainKeys는 발신자의 도메인을 인증하기 위해 공개 키 암호화의 한 형태를 사용하는 Yahoo에서 개발 중인 스팸 방지 소프트웨어 애플리케이션입니다. dkfilter는 Postfix를 위해 설계된 SMTP 프록시입니다. 이는 DomainKeys 메시지 서명 및 검증을 구현합니다. 두 개의 별도의 필터로 구성되어 있으며, 포트 587에서 나가는 이메일에 서명하기 위한 "outbound" 필터와 포트 25에서 들어오는 이메일의 서명을 검증하기 위한 "inbound" 필터가 있습니다. 이 문서는 도메인키 서명 및 검증을 배포하기 위해 postfix에 dkfilter를 설치하는 방법을 단계별로 설명합니다. ### 1 Postfix 설치 메일을 보내고 받을 수 있도록 도메인에 postfix를 설치합니다. ### 2 의존성 해결 - Perl 모듈 설치 Dkfilter는 Perl로 작성되었습니다. CPAN 아카이브에서 다음 Perl 모듈이 필요합니다. ```     * Crypt::OpenSSL::RSA     * Mail::Address     * MIME::Base64     * Net::DNS     * Test::More     * Text::Wrap     * Mail::DomainKeys ``` 다음 명령어가 도움이 될 것입니다. ``` perl -MCPAN -e'CPAN::Shell->install("Crypt::OpenSSL::RSA")' perl -MCPAN -e'CPAN::Shell->install("Mail::Address")' perl -MCPAN -e'CPAN::Shell->install("MIME::Base64")' perl -MCPAN -e'CPAN::Shell->install("Net::DNS")' perl -MCPAN -e'CPAN::Shell->install("Test::More")' perl -MCPAN -e'CPAN::Shell->install("Text::Wrap")' perl -MCPAN -e'CPAN::Shell->install("Email::Address")' perl -MCPAN -e'CPAN::Shell->install("Mail::DomainKeys")' ``` 참고: 위의 Perl 모듈을 설치하는 데 필요한 모든 종속 Perl 모듈도 해결하십시오. ### 3 dkfilter 설치 dkfilter를 설치하기 위해 다음 단계를 권장합니다: i. 다음 URL에서 dkfilter를 다운로드합니다: http://jason.long.name/dkfilter/dkfilter-0.11.tar.gz ii. dkfilter 설치 ``` tar xvf dkfilter-0.11.tar.gz cd dkfilter-0.11 ./configure --prefix=/usr/local/dkfilter make install useradd dkfilter ``` 필터 스크립트는 /usr/local/dkfilter/bin에 설치되고 Perl 모듈 파일은 /usr/local/dkfilter/lib에 위치합니다. ### 4 인바운드 필터 설정 서명을 확인하기 위해 들어오는 메일을 검사하도록 Postfix 구성 파일 내에서 관련 변경을 해야 합니다. vi /etc/postfix/master.cf ``` # # Before-filter SMTP server. Receive mail from the network and # pass it to the content filter on localhost port 10025. # smtp inet n - n - - smtpd -o smtpd_proxy_filter=127.0.0.1:10025 -o smtpd_client_connection_count_limit=10 # # After-filter SMTP server. Receive mail from the content filter on # localhost port 10026. # 127.0.0.1:10026 inet n - n - - smtpd -o smtpd_authorized_xforward_hosts=127.0.0.0/8 -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions= -o mynetworks=127.0.0.0/8 -o receive_override_options=no_unknown_recipient_checks ``` 위의 줄을 파일의 마지막에 삽입합니다. 여기서 우리는 메일이 127.0.0.1의 포트 10026에서 서명을 확인하기 위해 수신될 것임을 정의합니다. 서명 확인을 위해 수신 대기할 IP 주소를 정의할 수 있습니다. ### 5 아웃바운드 필터 설정 아웃바운드 필터는 메시지 서명에 사용되는 개인 키에 접근할 수 있어야 합니다. 또한, 사용 중인 키 선택기의 이름과 어떤 도메인에 대해 메시지를 서명해야 하는지 알아야 합니다. 이 정보는 dkfilter.out에 대한 명령줄 인수로 지정됩니다. 1. 개인/공개 키 쌍을 생성하고 공개 키를 DNS에 게시합니다. ``` cd /usr/local/dkfilter openssl genrsa -out private.key 1024 openssl rsa -in private.key -pubout -out public.key ``` 이렇게 하면 현재 디렉토리에 개인 키와 공개 키가 포함된 private.key 및 public.key 파일이 생성됩니다. private.key는 세계에서 읽을 수 없도록 설정하되, dkfilter 사용자에 의해 읽을 수 있도록 해야 합니다. 2. 선택기 이름을 선택합니다... 예: m1 3. 선택한 선택기 이름을 사용하여 DNS에 공개 키 데이터를 넣습니다. public.key 파일의 내용을 복사하고 PEM 헤더와 바닥글을 제거한 후 TXT 항목을 생성하여 DNS 영역 파일에 붙여넣습니다. 예: ``` _domainkey.sohailriaz.com IN TXT “t=y; o=-;” m1._domainkey.sohailriaz.com IN TXT "g=; k=rsa; p=MHwwDQYJK ... OprwIDAQAB;" ``` 여기서 m1은 마지막 단계에서 선택한 선택기의 이름이며 p= 매개변수는 공개 키를 하나의 긴 문자열로 포함합니다. 마지막으로, Postfix를 구성하여 아웃바운드 승인된 메시지를 포트 10027의 dkfilter.out 서비스만 통해 필터링하도록 설정합니다. 다음 예에서, 포트 587(제출 포트)을 통해 전송된 메시지는 DomainKeys로 서명된 메시지를 처리하는 After-Queue 콘텐츠 필터를 통과합니다. ``` vi /etc/postfix/master.cf ``` ``` # # modify the default submission service to specify a content filter # and restrict it to local clients and SASL authenticated clients only # submission inet n - n - - smtpd -o smtpd_etrn_restrictions=reject -o smtpd_sasl_auth_enable=yes -o content_filter=dksign:[127.0.0.1]:10027 -o receive_override_options=no_address_mappings -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject # # specify the location of the DomainKeys signing filter # dksign unix - - n - 10 smtp -o smtp_send_xforward_command=yes -o smtp_discard_ehlo_keywords=8bitmime # # service for accepting messages FROM the DomainKeys signing filter # 127.0.0.1:10028 inet n - n - 10 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o smtpd_authorized_xforward_hosts=127.0.0.0/8 ``` Postfix가 /etc/postfix/master.cf의 변경 사항에 응답하도록 postfix reload를 실행합니다. ``` postfix reload ``` ### 6 시작 스크립트 다음 사이트에서 시작/중지 스크립트를 다운로드합니다: http://www.enterux.com/files/dkfilter 해당 스크립트를 /etc/rc.d/init.d에 복사하고 필요에 따라 편집합니다. ### 7 참고 문헌 http://www.postfix.org http://antispam.yahoo.com/domainkeys http://jason.long.name/dkfilter/
Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.