제 09장 메일 전송 및 방어 Admin: #pSmtpQueue

권장사항: nextxch 앞단의 추가 계층으로 Proxmox Mail Gateway 사용

앞단의 메일 게이트웨이가 인터넷으로부터 모든 메일을 수신하고, 두 번째 독립형 안티스팸 및 안티바이러스 엔진으로 검사한 후 깨끗한 메일만 nextxch로 전달합니다. 이 페이지에서는 아키텍처, nextxch 앞단에 Proxmox Mail Gateway(오픈 소스, AGPLv3)를 단계별로 설정하는 방법 및 중요한 nextxch 설정에 대해 설명합니다.

운영 팁 및 아키텍처 참고 사항

게이트웨이는 선택 사항입니다. nextxch에는 자체 스팸 및 바이러스 차단 기능이 있습니다. 사용 시 주의사항: 게이트웨이 IP를 nextxch에서 신뢰할 수 있는 게이트웨이로 추가하십시오(5단계). 그러면 nextxch가 게이트웨이의 Received 헤더에서 실제 발신자 IP를 읽어와 게이트웨이 IP를 확인하는 대신 SPF, DMARC, 그레이리스팅 및 DNSBL을 올바르게 계속 평가합니다.

앞단에 게이트웨이를 두는 것이 유리한 이유

  • 심층 방어: 악의적인 메시지가 사서함에 도달하기 전에 두 개의 독립된 시스템이 실패해야 합니다. 한 제품의 취약성만으로는 충분하지 않습니다.
  • 두 번째 안티스팸 및 안티바이러스 엔진: Proxmox Mail Gateway는 자체 규칙, 베이지안 필터, SPF, DNSBL 및 ClamAV를 사용합니다. 한 필터가 놓치는 것을 다른 필터가 종종 잡아냅니다.
  • 격리함: 의심스러운 메시지는 게이트웨이에 보관되며 관리자나 사용자가 스팸 보고서를 통해 검토하고 해제할 수 있습니다.
  • 인터넷과의 격리: 게이트웨이만 포트 25에서 인터넷과의 연결을 수락합니다. nextxch는 그 뒤에 위치하며 포트 25는 게이트웨이에만 열려 있습니다.
  • 유지보수 중 버퍼링: 업데이트 또는 유지보수로 인해 nextxch를 일시적으로 사용할 수 없는 경우 게이트웨이가 수신 메시지를 큐에 보관하고 나중에 전달합니다.

객관적 평가: nextxch는 자체 스팸 보호(어댑티브 필터가 있는 SpamGuard, SPF/DKIM/DMARC/ARC, 그레이리스팅, DNSBL, 피싱 휴리스틱)를 기본 제공하며 최대 8개의 안티바이러스 엔진(Windows AMSI, YARA/Sanesecurity, Cymru MHR, MalwareBazaar, VirusTotal Hash, ClamAV, RFC 3507 ICAP, Rspamd/CLI)을 병렬로 오케스트레이션합니다. 대부분의 설치에는 이것으로 충분합니다. 앞단에 배치하는 게이트웨이는 선택 사항이며 다단계 필터링, 중앙 격리, 하나의 MX 뒤에 여러 메일 서버 또는 엄격한 네트워크 분리가 필요한 더 높은 요구사항에 유용합니다.

아키텍처: 인터넷 -> Proxmox Mail Gateway -> nextxch

MX 레코드는 게이트웨이를 가리킵니다. 포트 25에서 메일을 수신하고 필터링한 후 SMTP를 통해 nextxch로 전달합니다. 선택적으로 nextxch는 게이트웨이의 내부 포트 26을 통해 아웃바운드 메일을 보냅니다.

Mail flow with Proxmox Mail Gateway in front Inbound: internet to gateway on port 25, gateway to nextxch on port 25 with TLS. Outbound, optional: nextxch to gateway port 26, gateway to the internet on port 25. Internet Sending MTAs Recipient MX Proxmox Mail Gateway MX · port 25 external Receiver verification SPF · DNSBL · Greylisting Spam, viruses, quarantine Port 26 internal nextxch Port 25 from gateway only SpamGuard · 8-Engine-AV DKIM signing Mailboxes, groupware SMTP 25 · STARTTLS SMTP 25 · TLS Smart host · port 26 Delivery · port 25
실선: 인바운드 경로(필수). 파선: 스마트 호스트를 통한 아웃바운드 경로(선택 사항). 스마트 호스트가 없으면 nextxch는 DNS MX를 통해 아웃바운드 메일을 직접 계속 전달합니다.

Proxmox®는 Proxmox Server Solutions GmbH의 등록 상표입니다. 이 이름은 설명 목적으로만 사용되며, nextxch는 Proxmox Server Solutions GmbH와 제휴하지 않으며 보증이나 인증을 받지 않았습니다.

한눈에 보는 설정

이 순서로 메일 손실을 방지합니다: 게이트웨이를 먼저 완전히 설정하고 테스트한 다음 MX 레코드를 전환하고 마지막에 nextxch에서 25번 포트를 닫습니다.

참조 / 구성
1. Install Proxmox Mail Gateway (ISO, on Debian or as an LXC container)
2. Add relay domains (every domain nextxch accepts)
3. Default relay = nextxch host, port 25 (Mail Proxy -> Relaying)
4. Enable receiver verification, TLS and a certificate in the gateway
5. nextxch: add the gateway IP as a trusted gateway (SpamGuard)
6. Send a test message through the gateway, check Message Trace in nextxch
7. Switch the MX record to the gateway (remove the old MX only after the TTL expires)
8. Firewall: allow port 25 on nextxch from the gateway only
9. Optional outbound: gateway as smart host in nextxch (port 26, STARTTLS)

Example values on this page:
  Gateway:  pmg.company.com   203.0.113.25   (public, MX)
  nextxch:  mail.company.com  10.0.0.20      (internal, mailboxes)

1. Proxmox Mail Gateway 설치

Proxmox Mail Gateway는 독립형 어플라이언스(하드웨어의 ISO 설치 프로그램 또는 VM), 기존 Debian 시스템의 패키지 또는 LXC 컨테이너로 실행됩니다. Proxmox VE를 사용하는 경우 어플라이언스 관리자에서 바로 사용할 수 있는 컨테이너 템플릿을 사용할 수 있습니다. 이후 포트 8006의 웹 인터페이스를 통해 관리합니다.

참조 / 구성
Option A: ISO installer (hardware or VM)
  Download the ISO from proxmox.com/downloads -> boot -> run the installer
  Host name: pmg.company.com   (FQDN, matching the future MX and PTR)
  IP:        static IP, e.g. 203.0.113.25 or a DMZ address behind NAT

Option B: on an existing Debian system
  Add the Proxmox package repository and install the packages as described in
  "Install Proxmox Mail Gateway on Debian" in the PMG admin guide

Option C: LXC container in Proxmox VE
  Proxmox VE -> Storage -> CT Templates -> Templates -> section "mail"
  -> download the Proxmox Mail Gateway template -> create the container

Web interface:  https://pmg.company.com:8006   (port 8006 from the admin network only)

Repositories: without a subscription, add the "pmg-no-subscription" repository.
For production, Proxmox recommends the enterprise repository (with subscription).

2. 게이트웨이의 릴레이 도메인, 기본 릴레이 및 수신자 확인

모든 설정은 Configuration -> Mail Proxy 아래의 PMG 웹 인터페이스에 있습니다. 게이트웨이는 나열된 릴레이 도메인의 메일만 수락하고 필터링 후 기본 릴레이로 전달합니다.

참조 / 구성
Configuration -> Mail Proxy -> Relay Domains
  company.com
  company-group.com        (every domain configured in nextxch, including alias domains)

Configuration -> Mail Proxy -> Relaying
  Default Relay:      mail.company.com  (or 10.0.0.20)
  Relay Port:         25
  Relay Protocol:     SMTP
  Disable MX lookup:  yes               (address the nextxch host directly)

Configuration -> Mail Proxy -> Ports
  External SMTP Port: 25   (from the internet, untrusted)
  Internal SMTP Port: 26   (from nextxch, trusted, for outbound mail)

Configuration -> Mail Proxy -> Options
  Verify Receivers:   550   (reject unknown recipients right away)
  SPF:                yes
  DNSBL Sites:        e.g. zen.spamhaus.org   (observe the list's terms of use)

Several internal servers: Configuration -> Mail Proxy -> Transports
(domain or single address -> its own target server)

3. MX 레코드를 게이트웨이로 전환

게이트웨이를 통한 테스트 메시지가 nextxch에 도착한 후에만 전환하십시오(/admin/의 메시지 추적). 사전에 MX 레코드의 TTL을 몇 분으로 낮추십시오. nextxch 자체 레코드(A/AAAA, PTR, 자동 감지)는 변경하지 마십시오. 클라이언트는 nextxch에 직접 계속 연결됩니다.

참조 / 구성
; Gateway
pmg.company.com.      3600  IN  A     203.0.113.25
; PTR for 203.0.113.25 at your provider: pmg.company.com

; MX points to the gateway only
company.com.          3600  IN  MX 10 pmg.company.com.

; nextxch stays reachable for clients (IMAP, SMTP submission, webmail)
mail.company.com.     3600  IN  A     198.51.100.20

Test beforehand, without a DNS change:
  swaks --to anna.weber@company.com --server pmg.company.com --port 25 --tls

4. 선택적 아웃바운드: nextxch의 스마트 호스트로 게이트웨이 사용

아웃바운드 메일도 게이트웨이의 필터(예: 바이러스 검사, 통계)를 통과합니다. SMTP, 큐 제어 & 라이브 MX 테스터(#pSmtpQueue)의 관리자 콕핏에서 게이트웨이를 글로벌 스마트 호스트로 입력하거나, SMTP 경로를 사용하여 특정 발송자만 게이트웨이를 통해 전송하도록 하세요. 중요: 게이트웨이의 공인 IP는 도메인의 SPF 레코드에 포함되어야 하며, PTR은 게이트웨이의 HELO 이름과 일치해야 합니다.

참조 / 구성
# A) Global smart host: all outbound mail through the gateway
nextxch-cli update SmtpQueue --set outboundSmartHost=pmg.company.com \
  --set outboundSmartPort=26 --set outboundSmartHostTlsMode=StartTlsRequired

# B) Exception: one partner domain still directly via DNS MX (route without target host)
nextxch-cli create Route --set domain=partner.com --set bypassSmartHost=true \
  --set description="direct via MX, not through the gateway"

# C) Only certain senders through the gateway (#pSmtpQueue -> domain routes)
#    Destination domain:   *
#    Only for senders:     company.com, *.company.com   (SenderDomains)
#    Target host:          pmg.company.com:26           (several, comma-separated = failover)
#    TLS mode:             StartTlsRequired
#    Priority:             50                           (smaller = first; default 100)

# Add the gateway IP to the SPF record of the sender domain:
company.com.  IN  TXT  "v=spf1 mx ip4:203.0.113.25 -all"

# In the gateway: add the nextxch IP under Configuration -> Mail Proxy -> Networks
# if nextxch is not in the same subnet as the gateway.

5. nextxch에서 게이트웨이 IP를 신뢰함으로 추가

메일 게이트웨이가 메시지를 직접 수신한 후 다시 전달합니다. 이 경우 nextxch에게 전달하는 IP는 항상 게이트웨이 IP가 됩니다. SPF, DMARC, 그레이리스팅, DNSBL 및 리버스 DNS 검사가 실제 발신자를 올바르게 판단할 수 있도록, SpamGuard & ClamAV(#pSpam)의 "신뢰할 수 있는 게이트웨이(Trusted gateways)"에 해당 게이트웨이를 추가하십시오. 이 IP들로부터의 연결에 대해 nextxch는 게이트웨이가 작성한 Received 헤더에서 발신자 IP를 읽습니다. 헤더는 나열된 IP에서 온 연결에 대해서만 평가되므로, 직접 전달하는 발신자는 이 방식으로 자신의 IP를 위조할 수 없습니다. TrustedProxyCidrs(Cluster:EnableProxyProtocol)는 PROXY 프로토콜을 사용하는 HAProxy와 같은 TCP 프록시에만 적용되는 별개의 설정입니다.

참조 / 구성
# nextxch: add the gateway as trusted (public and internal IP, CIDR allowed)
# (admin cockpit: SpamGuard & ClamAV (#pSpam) -> "Trusted gateways")
nextxch-cli update SpamGuard --set trustedRelayCidrs=203.0.113.25,10.0.0.25

# Check: send a test message through the gateway, then in the spam analyzer or Message Trace
#   TRUSTED_RELAY  Via gateway 10.0.0.25, sender IP 198.51.100.7 from Received header
#   SPF_PASS       (SPF now checked against 198.51.100.7)

# Stays active in nextxch:
#   SPF/DKIM/DMARC/ARC, greylisting, DNSBL, adaptive content filter,
#   phishing heuristics, allow/block lists, ClamAV (if enabled)

# Connection limit: all inbound mail comes from one IP.
# Check MaxConnectionsPerIp (#pSmtpQueue, default 48) for high volumes.

6. 양쪽 레그의 방화벽 및 TLS

호스트 또는 경계 방화벽(Windows Firewall, nftables, pfSense/OPNsense)에서 nextxch의 25번 포트를 닫으십시오. nextxch IP 규칙은 모든 SMTP 포트에 일괄 적용되므로 클라이언트의 465 및 587 포트에도 영향을 미치므로 이 용도에는 적합하지 않습니다. 인터넷 <-> 게이트웨이 및 게이트웨이 <-> nextxch 양쪽 구간을 모두 암호화하십시오.

참조 / 구성
Firewall nextxch (inbound)
  TCP 25         only from 203.0.113.25 / 10.0.0.25 (gateway)
  TCP 465, 587   clients (SMTP submission)  -> stay open
  TCP 993, 443   clients (IMAP, webmail, DAV, push) -> stay open

Firewall gateway (inbound)
  TCP 25         from the internet
  TCP 26         from nextxch only (smart host, if used)
  TCP 8006       from the admin network only

TLS internet <-> gateway
  Configuration -> Mail Proxy -> TLS: "Enable TLS" on
  Certificate: Certificates -> ACME (Let's Encrypt) for pmg.company.com

TLS gateway -> nextxch
  nextxch offers STARTTLS on port 25 with the certificate of mail.company.com
  Gateway: TLS destination policy for mail.company.com = encrypt
           (or verify if the default relay is entered as a host name)

TLS nextxch -> gateway (smart host)
  outboundSmartHostTlsMode = StartTlsRequired

7. DKIM/DMARC, 회색 목록(greylisting) 및 역확산(backscatter)

실무에서 자주 간과되는 세 가지 사항. 게이트웨이는 아웃바운드 메일을 변경해서는 안 되며, 회색 리스트(greylisting)는 한 곳에서만 실행되어야 하고, 알 수 없는 수신자는 SMTP 대화 중에 거부되어야 합니다.

참조 / 구성
DKIM / DMARC
  - nextxch signs outbound mail with DKIM. The gateway forwards it unchanged.
  - No disclaimer rule for outbound mail and no content changes in the gateway
    (otherwise the DKIM signature breaks and DMARC fails at the recipient).
  - Leave DKIM signing off in the gateway; maintain disclaimers in nextxch if needed.

Greylisting
  - Slows down spam bots but delays first messages from new senders (usually < 30 minutes per PMG docs).
  - Run it in the gateway only; behind the gateway it would be ineffective in nextxch.
  - For time-critical senders (e.g. login codes, order confirmations) use the welcomelist,
    or skip greylisting entirely if the other filters are sufficient.

Avoid backscatter
  - Verify Receivers = 550: the gateway asks nextxch via RCPT TO whether the address exists.
  - nextxch rejects unknown recipients at RCPT TO, so the check takes effect immediately.
  - Catch-all addresses in nextxch defeat the check and should be avoided.

8. 라이선스 및 비용(2026년 11월 1일 기준)

Proxmox Mail Gateway는 GNU AGPLv3 오픈 소스로 제공되며 구독 없이 완전히 사용할 수 있습니다. 업데이트는 테스트 및 비운영 시스템용으로 Proxmox가 의도한 pmg-no-subscription 리포지토리에서 제공됩니다. 구독은 호스트 및 연도별로 적용되며, Proxmox에 따르면 무제한 사용자와 도메인이 포함되고 엔터프라이즈 리포지토리에 대한 액세스 권한을 제공합니다. 아래 가격은 Proxmox 가격 페이지에서 가져온 것이며 변경될 수 있습니다. proxmox.com이 항상 공식 기준입니다. nextxch는 Proxmox 구독을 판매하지 않습니다.

참조 / 구성
Licence:  GNU Affero General Public License v3 (AGPLv3), since PMG 5.0

Optional subscriptions per host and year (net, per proxmox.com, as of 1 Nov 2026):
  Community    EUR 190      no ticket support (forum)
  Basic        EUR 540      5 tickets/year, response 1 business day
  Standard     EUR 1,260    15 tickets/year, response 4 hours
  Premium      EUR 1,900    unlimited tickets, response 2 hours
  (response = first reply to critical requests within business hours)

Sources:
  https://www.proxmox.com/en/products/proxmox-mail-gateway/pricing
  https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html   (admin guide 9.1.1: licence, repositories, ports)

설정, 기본값 및 모범 사례

설정 / 위치 설명 기본값 프로덕션 모범 사례
PMG: Relay Domains (Mail Proxy) 게이트웨이가 메일을 수락하고 전달하는 도메인 목록. 다른 도메인으로 향하는 메일은 거부됩니다. leer 별칭 도메인을 포함하여 nextxch에 구성된 모든 도메인을 추가하십시오. nextxch에 도메인을 추가할 때 게이트웨이에도 추가하십시오.
PMG: Default Relay + Port (Mail Proxy -> Relaying) 필터링 후 인바운드 메일의 대상 (Postfix 전송). 전송(Transports)을 통한 도메인별 추가 내부 서버. Port 25 · SMTP mail.company.com 또는 10.0.0.20, 포트 25, 프로토콜 SMTP. 자체 MX 레코드가 있는 호스트 이름을 입력하는 경우 "MX 조회 비활성화"를 활성화하십시오.
PMG: Verify Receivers (Mail Proxy -> Options) 수신자 확인: 수락하기 전에 게이트웨이는 RCPT TO를 통해 nextxch에 해당 주소가 존재하는지 묻고 SMTP 대화 중에 알 수 없는 수신자를 거부합니다. aus 550으로 설정합니다. 게이트웨이가 나중에 반송해야 하는 존재하지 않는 주소의 메일을 수신하지 않으므로 백스캐터를 방지합니다.
PMG: TLS + Zertifikat 게이트웨이의 인바운드 및 아웃바운드 연결을 위한 STARTTLS. 자체 인증서가 없는 경우 PMG는 자체 서명 인증서를 생성합니다. TLS aus TLS를 켜고, pmg.company.com용 ACME(Let's Encrypt)를 통해 신뢰할 수 있는 인증서를 획득한 다음, nextxch 호스트에 대한 TLS 정책을 "encrypt"로 설정하십시오.
PMG: Disclaimer & DKIM-Signatur 면책 조항 규칙 작업은 본문에 텍스트를 추가하고, DKIM 서명은 내부 포트에서 수신한 메일에 서명합니다. aus 둘 다 꺼두세요. nextxch는 DKIM으로 서명합니다. 게이트웨이의 콘텐츠를 조금이라도 변경하면 서명이 무효화되어 DMARC에 위배됩니다. 면책 조항은 nextxch에서만 관리하세요(서명 전에 추가됨).
nextxch: Smart-Host (#pSmtpQueue · outboundSmartHost) 전역 스마트 호스트: 모든 아웃바운드 메일이 수신자 MX로 직접 전송되지 않고 이 릴레이로 전송됩니다. leer (direkt per MX) · Port 25 pmg.company.com, 릴레이 포트 26(게이트웨이 내부 포트), TLS 모드 StartTlsRequired, SMTP AUTH 없음. 게이트웨이의 Networks에 nextxch IP가 등록되어 있어야 합니다(동일 서브넷은 자동으로 허용됨).
nextxch: Route · SenderDomains SMTP 라우트의 발신자 조건: 도메인(company.com, *.company.com) 또는 주소(billing@company.com, *@company.com). 비어 있음 = 모든 발신자. leer 게이트웨이를 통해 특정 테넌트만 전송: 대상 도메인 * 및 SenderDomains = company.com, 대상 호스트 pmg.company.com:26인 라우트.
nextxch: Route · Priority 동일한 우선순위의 경로 간 순서; 숫자가 작을수록 우선하며, 그 다음으로 더 구체적인 패턴이 우선합니다. 100 우선순위보다 순위가 앞섭니다: 발신자 + 대상 도메인, 그다음 대상 도메인, 그다음 발신자 전용(대상 *), 그다음 *, 그다음 글로벌 스마트 호스트, 그다음 DNS MX.
nextxch: Route · BypassSmartHost 대상 호스트가 없는 라우팅 전용: 글로벌 스마트 호스트가 설정된 경우에도 이 도메인으로 향하는 메일은 DNS MX를 통해 직접 전송됩니다. false 게이트웨이를 거치지 않아야 하는 개별 파트너 도메인의 경우. 라우트에 대상 호스트가 있는 경우 이 스위치는 무시됩니다.
nextxch: Vertrauenswürdige Gateways (#pSpam · trustedRelayCidrs) 업스트림 게이트웨이의 IP 또는 CIDR 네트워크. 이들로부터 연결이 들어오면, nextxch는 나열된 게이트웨이 또는 로컬호스트에 의해 작성되지 않은 가장 상단의 Received 헤더에서 발신자 IP와 HELO를 가져옵니다. leer 공개 및 내부 겔이트웨이 IP(예: 203.0.113.25 및 10.0.0.25)를 추가하십시오. 자체 게이트웨이만 해당: 나열된 IP의 Received 헤더는 신뢰할 수 있는 것으로 간주됩니다. 그러면 스팸 분석기에 감지된 발신자 IP와 함께 TRUSTED_RELAY 규칙이 표시됩니다.
nextxch: SPF, DKIM, DMARC & ARC, Greylisting, DNSBL (#pSpam) 게이트웨이가 나열된 경우 수신 서버는 실제 발신자 IP를 확인합니다. 게이트웨이가 없으면 게이트웨이 IP만 확인하게 되므로 다른 도메인의 경우 SPF가 주로 softfail 또는 fail을 반환하게 됩니다. abhängig von der Konfiguration 켜두세요. 게이트웨이와 nextxch 모두에서 검사하는 것은 무해합니다. 한 곳에서만 회색 나열(greylisting)을 사용하려면 게이트웨이에서 유지하고 nextxch에서는 끄세요.
Firewall: Port 25 auf nextxch MX 전환 후에는 게이트웨이만 포트 25에서 nextxch에 도달할 수 있습니다. offen für alle 호스트 또는 경계 방화벽에서 203.0.113.25 또는 내부 게이트웨이 IP에서만 25번 포트를 허용하십시오. 465, 587, 993, 443번 포트는 클라이언트를 위해 열려 있습니다.