Bab 09 Transportasi & Pertahanan Surat Admin: #pSmtpQueue

Rekomendasi: Proxmox Mail Gateway sebagai lapisan tambahan di depan nextxch

Sebuah gateway email di depan menerima semua email dari internet, memeriksanya dengan mesin anti-spam dan antivirus kedua yang independen, dan hanya meneruskan email bersih ke nextxch. Halaman ini menunjukkan arsitektur, penyiapan langkah demi langkah Proxmox Mail Gateway (open source, AGPLv3) di depan nextxch, dan pengaturan nextxch yang penting.

Tips Operasional & Catatan Arsitektur

Gateway bersifat opsional: nextxch memiliki perlindungan spam dan virus sendiri. Penting jika Anda menggunakannya: tambahkan IP gateway di nextxch sebagai gateway tepercaya (langkah 5). nextxch kemudian membaca IP pengirim asli dari header Received gateway dan terus mengevaluasi SPF, DMARC, greylisting, dan DNSBL dengan benar alih-alih memeriksa IP gateway.

Mengapa gateway di depan dapat masuk akal

  • Pertahanan lapis demi lapis: Dua sistem independen harus gagal sebelum pesan berbahaya mencapai kotak surat. Kelemahan pada satu produk saja tidak cukup.
  • Mesin antispam dan antivirus kedua: Proxmox Mail Gateway menggunakan aturan sendiri, filter Bayesian, SPF, DNSBL, dan ClamAV. Apa yang dilewati satu filter sering kali ditangkap oleh yang lain.
  • Karantina: Pesan mencurigakan disimpan di gateway dan dapat ditinjau serta dilepaskan oleh administrator atau pengguna melalui laporan spam.
  • Pemisahan dari internet: Hanya gateway yang menerima koneksi dari internet pada port 25. nextxch berada di belakangnya, dengan port 25 terbuka hanya untuk gateway.
  • Penyangga selama pemeliharaan: Jika nextxch tidak tersedia untuk sementara waktu karena pembaruan atau pemeliharaan, gateway menyimpan pesan masuk dalam antrean dan mengirimkannya sesudahnya.

Penilaian yang jujur: nextxch dikirimkan dengan perlindungan spam sendiri (SpamGuard dengan filter adaptif, SPF/DKIM/DMARC/ARC, greylisting, DNSBL, heuristik phishing) dan mengorkestrasikan hingga 8 mesin antivirus secara paralel (Windows AMSI, YARA/Sanesecurity, Cymru MHR, MalwareBazaar, VirusTotal Hash, ClamAV, RFC 3507 ICAP, Rspamd/CLI). Untuk sebagian besar instalasi, itu sudah cukup. Gateway di depan bersifat opsional dan berguna untuk kebutuhan yang lebih tinggi: kebijakan yang menuntut pemfilteran multi-tahap, karantina pusat, beberapa server email di belakang satu MX, atau pemisahan jaringan yang ketat.

Arsitektur: internet -> Proxmox Mail Gateway -> nextxch

Record MX menunjuk ke gateway. Ini menerima surat pada port 25, memfilternya, dan meneruskannya melalui SMTP ke nextxch. Secara opsional, nextxch mengirimkan surat keluar melalui port internal gateway 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
Garis bersambung: jalur masuk (wajib). Garis putus-putus: jalur keluar melalui gateway sebagai smart host (opsional). Tanpa smart host, nextxch terus mengirimkan surat keluar secara langsung melalui DNS MX.

Proxmox® adalah merek dagang terdaftar dari Proxmox Server Solutions GmbH. Nama ini digunakan hanya untuk deskripsi; nextxch tidak berafiliasi dengan Proxmox Server Solutions GmbH dan tidak didukung maupun disertifikasi olehnya.

Ikhtisar Pengaturan

Urutan ini menghindari kehilangan surel: siapkan dan uji gateway sepenuhnya terlebih dahulu, lalu alihkan record MX, dan tutup port 25 di nextxch terakhir.

Referensi / Konfigurasi
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. Pasang Proxmox Mail Gateway

Proxmox Mail Gateway berjalan sebagai peranti mandiri (pemasang ISO pada perangkat keras atau sebagai VM), sebagai paket pada sistem Debian yang ada atau sebagai wadah LXC. Jika Anda menggunakan Proxmox VE, templat wadah siap pakai tersedia di pengelola peranti. Setelah itu, Anda mengelolanya melalui antarmuka web pada port 8006.

Referensi / Konfigurasi
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. Domain relai, relai default, dan verifikasi penerima di gateway

Semua pengaturan ada di antarmuka web PMG di bawah Konfigurasi -> Mail Proxy. Gateway hanya menerima email untuk domain relay terdaftar dan meneruskannya ke relay default setelah pemfilteran.

Referensi / Konfigurasi
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. Alihkan catatan MX ke gateway

Ganti hanya setelah pesan uji melalui gateway tiba di nextxch (Message Trace di /admin/). Turunkan TTL record MX ke beberapa menit sebelumnya. Jangan ubah record untuk nextxch itu sendiri (A/AAAA, PTR, Autodiscover): klien terus terhubung langsung ke nextxch.

Referensi / Konfigurasi
; 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. Keluar opsional: gateway sebagai smart host di nextxch

Email keluar kemudian juga melewati filter gateway (mis. pemindaian virus, statistik). Di kokpit admin di bawah SMTP, Queue Controls & Live MX Tester (#pSmtpQueue), masukkan gateway sebagai smart host global, atau gunakan rute SMTP untuk mengirim pengirim tertentu saja melalui gateway. Penting: IP publik gateway kemudian harus berada di catatan SPF domain Anda, dan PTR-nya harus cocok dengan nama HELO gateway.

Referensi / Konfigurasi
# 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. Tambahkan IP gateway di nextxch sebagai tepercaya

Gateway email menerima pesan tersebut dan mengirimkannya lagi. Bagi nextxch, IP pengirim kemudian selalu menjadi IP gateway. Agar SPF, DMARC, greylisting, DNSBL, dan pemeriksaan DNS terbalik tetap menilai pengirim sebenarnya, tambahkan gateway di bawah SpamGuard & ClamAV (#pSpam) pada "Trusted gateways". Untuk koneksi dari IP ini, nextxch membaca IP pengirim dari header Received yang ditulis oleh gateway. Header hanya dievaluasi untuk koneksi dari IP yang terdaftar, sehingga pengirim yang mengirim langsung tidak dapat memalsukan IP-nya dengan cara ini. TrustedProxyCidrs (Cluster:EnableProxyProtocol) adalah hal yang berbeda: mereka hanya berlaku untuk proxy TCP seperti HAProxy yang menggunakan protokol PROXY.

Referensi / Konfigurasi
# 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. Firewall dan TLS di kedua sisi

Tutup port 25 pada nextxch di firewall host atau perimeter (Windows Firewall, nftables, pfSense/OPNsense). Aturan IP nextxch tidak cocok untuk ini karena berlaku untuk semua port SMTP secara bersamaan dan oleh karena itu juga akan mengenai port 465 dan 587 klien. Enkripsi kedua sisi: internet <-> gateway dan gateway <-> nextxch.

Referensi / Konfigurasi
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, dan backscatter

Tiga poin yang sering diabaikan dalam praktiknya. Gateway tidak boleh mengubah surat keluar, greylisting harus berjalan di satu tempat saja, dan penerima yang tidak dikenal harus ditolak selama dialog SMTP.

Referensi / Konfigurasi
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. Lisensi dan biaya (per 1 Nov 2026)

Proxmox Mail Gateway bersifat sumber terbuka di bawah GNU AGPLv3 dan sepenuhnya dapat digunakan tanpa langganan; pembaruan kemudian berasal dari repositori pmg-no-subscription, yang dimaksudkan oleh Proxmox untuk sistem pengujian dan non-produksi. Langganan berlaku per host dan tahun, menurut Proxmox mencakup pengguna dan domain tak terbatas, serta memberikan akses ke repositori perusahaan. Harga di bawah ini berasal dari halaman harga Proxmox dan dapat berubah; proxmox.com selalu menjadi rujukan utama. nextxch tidak menjual langganan Proxmox.

Referensi / Konfigurasi
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)

Pengaturan, Nilai Default & Praktik Terbaik

Pengaturan / Lokasi Deskripsi Nilai Default Praktik Terbaik Produksi
PMG: Relay Domains (Mail Proxy) Daftar domain tempat gateway menerima dan meneruskan surat. Surat ke domain lain ditolak. leer Tambahkan setiap domain yang dikonfigurasi di nextxch, termasuk domain alias. Saat Anda menambahkan domain di nextxch, tambahkan juga ke gateway.
PMG: Default Relay + Port (Mail Proxy -> Relaying) Tujuan untuk email masuk setelah pemfilteran (transportasi Postfix). Server internal tambahan per domain melalui Transpor. Port 25 · SMTP mail.company.com atau 10.0.0.20, port 25, protokol SMTP. Aktifkan "Nonaktifkan pencarian MX" jika Anda memasukkan nama host yang memiliki catatan MX sendiri.
PMG: Verify Receivers (Mail Proxy -> Options) Verifikasi penerima: sebelum menerima, gateway menanyakan nextxch melalui RCPT TO apakah alamat tersebut ada dan menolak penerima yang tidak dikenal selama dialog SMTP. aus Atur ke 550. Mencegah backscatter karena gateway tidak pernah menerima email untuk alamat fiktif yang kemudian harus dipantulkan.
PMG: TLS + Zertifikat STARTTLS untuk koneksi masuk dan keluar gateway. Tanpa sertifikatnya sendiri, PMG menghasilkan sertifikat yang ditandatangani sendiri. TLS aus Nyalakan TLS, dapatkan sertifikat tepercaya melalui ACME (Let's Encrypt) untuk pmg.company.com dan tetapkan kebijakan TLS "encrypt" untuk host nextxch.
PMG: Disclaimer & DKIM-Signatur Aksi aturan Penafian menambahkan teks ke badan pesan; Penandatanganan DKIM menandatangani surat yang diterima pada port internal. aus Biarkan keduanya nonaktif. nextxch menandatangani dengan DKIM; perubahan apa pun pada konten di gateway akan merusak tanda tangan dan oleh karena itu DMARC. Pertahankan penafian hanya di nextxch (ditambahkan sebelum penandatanganan).
nextxch: Smart-Host (#pSmtpQueue · outboundSmartHost) Smart host global: semua email keluar dikirim ke relay ini alih-alih langsung ke MX penerima. leer (direkt per MX) · Port 25 pmg.company.com, port relay 26 (port internal gateway), mode TLS StartTlsRequired, tanpa SMTP AUTH. Di dalam gateway, IP nextxch harus tercantum di bawah Networks (subnet yang sama diizinkan secara otomatis).
nextxch: Route · SenderDomains Kondisi pengirim dari rute SMTP: domain (company.com, *.company.com) atau alamat (billing@company.com, *@company.com). Kosong = setiap pengirim. leer Kirim hanya tenant tertentu melalui gateway: rute dengan domain tujuan * dan SenderDomains = company.com, host target pmg.company.com:26.
nextxch: Route · Priority Urutan di antara rute dengan peringkat yang sama; angka yang lebih kecil menang, lalu pola yang lebih spesifik. 100 Peringkat didahulukan daripada prioritas: domain pengirim + tujuan, lalu domain tujuan, lalu pengirim saja (tujuan *), lalu *, lalu smart host global, lalu DNS MX.
nextxch: Route · BypassSmartHost Hanya untuk rute tanpa host target: surat ke domain ini berjalan langsung melalui DNS MX bahkan ketika smart host global diatur. false Untuk domain mitra individual yang tidak boleh melewati gateway. Jika rute memiliki host target, pengalihan diabaikan.
nextxch: Vertrauenswürdige Gateways (#pSpam · trustedRelayCidrs) IP atau jaringan CIDR dari gateway hulu. Ketika sambungan berasal dari sana, nextxch mengambil IP pengirim dan HELO dari tajuk Received teratas yang tidak ditulis oleh gateway terdaftar atau localhost. leer Tambahkan IP gateway publik dan internal, mis. 203.0.113.25 dan 10.0.0.25. Hanya gateway Anda sendiri: Header Received dari IP yang terdaftar dianggap benar. Penganalisis spam kemudian menunjukkan aturan TRUSTED_RELAY dengan IP pengirim yang terdeteksi.
nextxch: SPF, DKIM, DMARC & ARC, Greylisting, DNSBL (#pSpam) Dengan gateway yang tercantum, mereka memeriksa IP pengirim asli. Tanpa itu, mereka hanya akan melihat IP gateway, dan SPF sebagian besar akan mengembalikan softfail atau fail untuk domain lain. abhängig von der Konfiguration Biarkan aktif. Memeriksa di gateway dan nextxch tidak berbahaya; jika Anda ingin greylisting di satu tempat saja, pertahankan di gateway dan nonaktifkan di nextxch.
Firewall: Port 25 auf nextxch Setelah peralihan MX, hanya gateway yang dapat menjangkau nextxch pada port 25. offen für alle Di host atau perimeter firewall, izinkan port 25 hanya dari 203.0.113.25 atau IP gateway internal. Port 465, 587, 993, dan 443 tetap terbuka untuk klien.