메일 서버 · 4 min read · Jan 16, 2026

Postfix에 amavisd-new 통합하기 - 스팸 및 바이러스 스캔 - 페이지 2

3 Debian Sarge

변동 패키지인 ClamAV의 경우 (ClamAV의 새로운 릴리스가 매우 자주 발생합니다), Debian-volatile 저장소가 존재합니다 (이 글을 작성할 당시 Sarge와 Woody에만 해당됩니다). 최신 ClamAV 패키지를 설치하기 위해 먼저 /etc/apt/sources.list를 편집하고 다음 줄을 추가합니다:

vi /etc/apt/sources.list

| [...] deb http://volatile.debian.net/debian-volatile sarge/volatile main contrib non-free |

그 후, 다음 명령어를 실행하여 패키지 데이터베이스를 업데이트합니다:

apt-get update

그 다음, amavisd-new, SpamAssassin 및 ClamAV와 몇 가지 다른 프로그램(주로 amavisd-new가 아카이브를 풀기 위해 필요한 프로그램)을 함께 설치합니다:

apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip unarj bzip2 unzoo libnet-ph-perl libnet-snpp-perl libnet-telnet-perl nomarch lzop

몇 가지 질문이 있을 것입니다:

바이러스 데이터베이스 업데이트 방법: <– daemon
로컬 데이터베이스 미러 사이트: <– db.de.clamav.net (독일; 가장 가까운 미러를 선택하세요)
HTTP 프록시 정보 (없으면 비워두세요): <– (비어 있음)
업데이트 후 clamd에 알림을 보내야 합니까? <– 예

그 후, /etc/amavis/amavisd.conf를 편집하여 amavisd-new를 구성해야 합니다. 이 파일은 매우 길고 많은 주석이 포함되어 있습니다. 대부분의 기본 설정은 괜찮지만, @bypass_virus_checks_acl 및 @bypass_spam_checks_acl이 주석 처리되어 있는지 확인해야 합니다. 그렇지 않으면 amavisd-new가 안티 스팸/-바이러스 코드를 로드하지 않습니다 (내 복사본에서는 @bypass_spam_checks_acl 줄이 활성화되어 있었으므로 주석 처리해야 했습니다):

vi /etc/amavis/amavisd.conf

| [...] # @bypass_virus_checks_acl = qw( . ); # uncomment to DISABLE anti-virus code [...] # @bypass_spam_checks_acl = qw( . ); # No default dependency on spamassassin [...] |

그런 다음 같은 파일에서 스팸 설정 및 스팸/바이러스 메일에 대한 작업을 살펴봐야 합니다. 기본 설정이 괜찮다면 아무것도 변경할 필요가 없습니다. 이 파일에는 많은 설명이 포함되어 있으므로 설정을 여기서 설명할 필요는 없습니다:

| [...] $final_virus_destiny = D_DISCARD; # (defaults to D_BOUNCE) $final_banned_destiny = D_BOUNCE; # (defaults to D_BOUNCE) $final_spam_destiny = D_REJECT; # (defaults to D_REJECT) $final_bad_header_destiny = D_PASS; # (defaults to D_PASS), D_BOUNCE suggested [...] $virus_admin = "postmaster\@$mydomain"; # due to D_DISCARD default [...] $QUARANTINEDIR = '/var/lib/amavis/virusmails'; #$virus_quarantine_method = "local:virus-%i-%n"; # default #$spam_quarantine_method = "local:spam-%b-%i-%n"; # default $virus_quarantine_to = 'virus-quarantine'; # traditional local quarantine $spam_quarantine_to = 'spam-quarantine'; [...] $sa_local_tests_only = 1; # (default: false) #$sa_auto_whitelist = 1; # turn on AWL (default: false) # Timout for SpamAssassin. This is only used if spamassassin does NOT # override it (which it often does if sa_local_tests_only is not true) $sa_timeout = 30; # timeout in seconds for a call to SpamAssassin # (default is 30 seconds, undef disables it) # AWL (auto whitelisting), requires spamassassin 2.44 or better # $sa_auto_whitelist = 1; # defaults to undef $sa_mail_body_size_limit = 150*1024; # don't waste time on SA is mail is larger # (less than 1% of spam is > 64k) # default: undef, no limitations # default values, can be overridden by more specific lookups, e.g. SQL $sa_tag_level_deflt = 4.0; # add spam info headers if at, or above that level $sa_tag2_level_deflt = 6.31; # add 'spam detected' headers at that level $sa_kill_level_deflt = $sa_tag2_level_deflt; # triggers spam evasive actions # at or above that level: bounce/reject/drop, # quarantine, and adding mail address extension $sa_dsn_cutoff_level = 10; # spam level beyond which a DSN is not sent, # effectively turning D_BOUNCE into D_DISCARD; # undef disables this feature and is a default; $sa_spam_subject_tag = '*SPAM* '; # (defaults to undef, disabled) [...] |

그 후, clamav 사용자를 amavis 그룹에 추가하고 amavisd-new 및 ClamAV를 재시작하는 명령어를 실행합니다:

adduser clamav amavis  
 /etc/init.d/amavis restart  
 /etc/init.d/clamav-daemon restart

다음으로 Freshclam 데몬의 구성 파일을 편집해야 합니다 (이 데몬은 정기적으로 자동으로 ClamAV 미러에서 최신 바이러스 서명을 가져옵니다) 왜냐하면 작은 버그가 포함되어 있기 때문입니다. /etc/clamav/freshclam.conf를 열고 NotifyClamd 줄을 아래와 같이 수정합니다:

vi /etc/clamav/freshclam.conf

| [...] NotifyClamd /etc/clamav/clamd.conf [...] |

그런 다음 Freshclam을 재시작합니다 (다른 ClamAV 설치의 Freshclam 프로세스가 실행 중이지 않은지 확인하세요. 그렇지 않으면 우리의 Freshclam이 시작되지 않습니다):

/etc/init.d/clamav-freshclam restart

이제 Postfix를 구성하여 수신 이메일을 amavisd-new를 통해 파이프해야 합니다:

postconf -e 'content_filter = amavis:[127.0.0.1]:10024'  
 postconf -e 'receive_override_options = no_address_mappings'

그 후, 다음 줄을 /etc/postfix/master.cf에 추가합니다:

vi /etc/postfix/master.cf

| [...] amavis unix - - - - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes 127.0.0.1:10025 inet n - - - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_bind_address=127.0.0.1 |

그런 다음 Postfix를 재시작합니다:

/etc/init.d/postfix restart

이제 다음 명령어를 실행합니다:

netstat -tap

그러면 Postfix (master)가 포트 25 (smtp)와 10025에서, amavisd-new가 포트 10024에서 수신 대기 중인 것을 볼 수 있어야 합니다:

server1:~# netstat -tap  
 Active Internet connections (servers and established)  
 Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name  
 tcp        0      0 localhost.localdo:10024 *:*                     LISTEN     4369/amavisd (maste  
 tcp        0      0 localhost.localdo:10025 *:*                     LISTEN     4895/master  
 tcp        0      0 *:874                   *:*                     LISTEN     1964/rpc.statd  
 tcp        0      0 *:sunrpc                *:*                     LISTEN     1553/portmap  
 tcp        0      0 *:auth                  *:*                     LISTEN     1932/inetd  
 tcp        0      0 *:smtp                  *:*                     LISTEN     4895/master  
 tcp6       0      0 *:imaps                 *:*                     LISTEN     3177/couriertcpd  
 tcp6       0      0 *:pop3s                 *:*                     LISTEN     3094/couriertcpd  
 tcp6       0      0 *:pop3                  *:*                     LISTEN     3038/couriertcpd  
 tcp6       0      0 *:imap2                 *:*                     LISTEN     3129/couriertcpd  
 tcp6       0      0 *:ssh                   *:*                     LISTEN     1943/sshd  
 tcp6       0      0 *:smtp                  *:*                     LISTEN     4895/master  
 tcp6       0    148 localhost:ssh           localhost:4631          ESTABLISHED2052/0

원하신다면 Razor, Pyzor 및 DCC를 SpamAssassin에 추가하여 필터링 성능을 향상시킬 수 있습니다. Razor, Pyzor 및 DCC는 협업 필터링 네트워크를 사용하는 스팸 필터입니다. 설치하려면 다음 명령어를 실행하세요:

apt-get install razor pyzor dcc-client

이제 SpamAssassin에 이 세 프로그램을 사용하도록 지시해야 합니다. /etc/spamassassin/local.cf를 편집하고 다음 줄을 추가합니다:

vi /etc/spamassassin/local.cf

| [...] # dcc use_dcc 1 dcc_path /usr/bin/dccproc dcc_add_header 1 dcc_dccifd_path /usr/sbin/dccifd #pyzor use_pyzor 1 pyzor_path /usr/bin/pyzor pyzor_add_header 1 #razor use_razor2 1 razor_config /etc/razor/razor-agent.conf #bayes use_bayes 1 use_bayes_rules 1 bayes_auto_learn 1 |

그 후 amavisd-new를 재시작합니다:

/etc/init.d/amavis restart

이제 모든 것이 완료되었습니다. 이제 메일 로그 (/var/log/mail.log)를 주시하여 amavisd-new가 제대로 작동하는지 확인하세요. amavisd-new는 스팸 또는 바이러스 이메일을 찾을 때마다 로그를 기록합니다. amavisd-new를 (재)시작할 때 스팸 및 바이러스 스캔 코드를 로드한다고 로그를 기록해야 합니다 (그렇지 않으면 아마도 잘못된 작업을 했을 것입니다).

메일 로그를 실시간으로 보려면 다음 명령어를 사용할 수 있습니다:

tail -f /var/log/mail.log

(로그를 나가려면 CTRL + c를 누르세요.)

4 링크

Share: X/Twitter LinkedIn

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

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