פרק 09 העברת דואר והגנה Admin: #pSmtpQueue

המלצה: Proxmox Mail Gateway כשכבה נוספת לפני nextxch

שער דואר קדמי מקבל את כל הדואר מהאינטרנט, בודק אותו באמצעות מנוע אנטי-ספאם ואנטי-וירוס שני ועצמאי ומעביר רק דואר נקי אל nextxch. עמוד זה מציג את הארכיטקטורה, הגדרה שלב אחר שלב של Proxmox Mail Gateway (קוד פתוח, AGPLv3) לפני nextxch ואת הגדרות nextxch החשובות.

טיפ תפעולי וערת ארכיטקטורה

השער הוא אופציונלי: ל-nextxch יש הגנה משל עצמו מפני ספام ווירוסים. חשוב אם אתה משתמש בו: הוסף את כתובת ה-IP של השער ב-nextxch כשער מהימן (שלב 5). nextxch קורא לאחר מכן את כתובת ה-IP האמיתית של השולח מהכותרת Received של השער וממשיך להعריך SPF, DMARC, greylisting ו-DNSBL כהלכה במקום לבדוק את כתובת ה-IP של השער.

מדוע שער גישה בחזית עשוי להגיון

  • הגנה בעומק (Defense in depth): שני מערכות בלתי תלויות חייבות להיכשל לפני הודעה זדונית מגיעה לתיבת דואר. חולשה במוצר אחד אינה מספיקה כשלעצמה.
  • מנוע אנטי-ספאם ואנטי-וירוס שני: Proxmox Mail Gateway משתמש בכללים משלו, במסנן בייסיאני, ב-SPF, ב-DNSBL וב-ClamAV. מה שמסנן אחד מפספס, השני לעיתים קרובות תופס.
  • הסגר (Quarantine): הודעות חשודות מוחזקות בשער וניתן לסקור ולשחרר אותן על ידי מנהלי מערכת או משתמשים דרך דוח הספאם.
  • ניתוק מהאינטרנט: רק שער הגישה מקבל חיבורים מהאינטרנט ביציאה 25. nextxch יושב מאחוריו, כאשר יציאה 25 פתוחה לשער הגישה בלבד.
  • חציצה במהלך תחזוקה: אם nextxch אינו זמין זמנית לצורך עדכון או תחזוקה, שער הגישה שומר את ההודעות הנכנסות בתור שלו ומספק אותן לאחר מכן.

הערכה כנה: nextxch מגיע עם הגנת ספאם משל עצמו (SpamGuard עם מסנן אדפטיבי, SPF/DKIM/DMARC/ARC, greylisting, DNSBL, heuristiques פישינג) ומנהל עד 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, וסגור את פורט 25 ב-nextxch אחרון.

הפניה / תצורה
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. דומיינים ממסרים, ממסר ברירת מחדל ואימות מקבטים בשער (gateway)

כל ההגדרות נמצאות בממשק ה-Web של PMG תחת Configuration -> Mail Proxy. השער מקבל דואר רק עבור דומייני ממסר רשומים ומעביר אותו לממסר ברירת המחדל לאחר סינון.

הפניה / תצורה
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/). הנמך מראש את ה-TTL של רשומות ה-MX למספר דקות. אל תشנה את הרשומות עבור nextxch עצמו (A/AAAA, PTR, Autodiscover): לקוחות ממשיכים להתחבר ישירות אל 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. יוצא אופציונלי: שער כ-smart host ב-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. הוספת כתובת ה-IP של השער ב-nextxch כמהימנה

שער דואר מקבל את ההודעה בעצמו ומסר אותה מחדש. עבור nextxch, כתובת ה-IP המסורת תמיד תהיה כתובת ה-IP של השער. כדי ש-SPF, DMARC, greylisting, DNSBL ובדיקת ה-DNS ההפוך ימשיכו לשפוט את השולח האמיתי, הוסף את השער תחת SpamGuard & ClamAV (#pSpam) בתוך "שערים מהימנים". עבור חיבורים מכתובות IP אלו, nextxch קורא את כתובת ה-IP של השולח מכותרת ה-Received שהשער כתב. כותרות נבדקות רק עבור חיבורים מכתובות IP ברשימה, כך ששולח הממסר ישירות אינו יכול לזייף את כתובת ה-IP שלו בדרך זו. TrustedProxyCidrs (Cluster:EnableProxyProtocol) הם משהו אחר: הם חלים אך ורק על פרוקסי TCP כגון HAProxy המשתמשים בפרוטוקול PROXY.

הפניה / תצורה
# 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 בשתי הרגליים

סגור את פורט 25 ב-nextxch בתוכנת ההגנה או בחומת האש ההיקפית (Windows Firewall, nftables, pfSense/OPNsense). כללי ה-IP של nextxch אינם מתאימים לכך מכיוון שהם חלים על כל פורטי ה-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. רישיון ועלות (נכון ל-1 בנובמבר 2026)

Proxmox Mail Gateway הוא בקוד פתוח תחת רישיון GNU AGPLv3 וניתן לשימוש מלא ללא מנוי; עדכונים מגיעים לאחר מכן ממאגר pmg-no-subscription, שProxmox ייעדה למערכות בדיקה ולא לייצור. מנוי חל לכל מארח ושנה, לפי 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, כולל דומיינים של כינויים (aliases). כאשר אתה מוסיף דומיין ב-nextxch, הוסף אותו גם לשער (gateway).
PMG: Default Relay + Port (Mail Proxy -> Relaying) יעד עבור דואר נכנס לאחר סינון (תעבורת Postfix). שרתים פנימיים נוספים לכל דומיין באמצעות תעבורה (Transports). Port 25 · SMTP mail.company.com or 10.0.0.20, port 25, protocol SMTP. Enable "Disable MX lookup" if you enter a host name that has an MX record of its own.
PMG: Verify Receivers (Mail Proxy -> Options) אימות נמען: לפני הקבלה, שער הגישה שואל את nextxch דרך RCPT TO האם הכתובת קיימת ודוחה נמענים לא ידועים במהלך דו-שיח ה-SMTP. aus הגדר ל-550. מונע חזרה (backscatter) משום שהשער לעולם אינו מקבל דואר עבור כתובות מומצאות שהיה עליו להחזיר מאוחר יותר.
PMG: TLS + Zertifikat STARTTLS for inbound and outbound connections of the gateway. Without a certificate of its own, PMG generates a self-signed one. TLS aus הפעל את TLS, השג אישור מהימן באמצעות ACME (Let's Encrypt) עבור pmg.company.com והגדר מדיניות TLS של "encrypt" עבור מארח nextxch.
PMG: Disclaimer & DKIM-Signatur פעולת כלל כתב הוויתור מוסיפה טקסט לגוף ההודעה; חתימת DKIM חותמת דואר שמתקבל בפורט הפנימי. aus השאר את שניהם כבויים. nextxch חותם באמצעות DKIM; כל שינוי בתוכן בשער שובר את החתימה ולכן גם את DMARC. שמור הסתייגויות ב-nextxch בלבד (מוסיפים לפני החתימה).
nextxch: Smart-Host (#pSmtpQueue · outboundSmartHost) Smart host גלובלי: כל הדואר היוצא עובר לממסר זה במקום ישירות ל-MX של הנמען. leer (direkt per MX) · Port 25 pmg.company.com, יציאת ממסר 26 (היציאה הפנימית של השער), מצב TLS מסוג StartTlsRequired, ללא אימות SMTP. בשער, כתובת ה-IP של nextxch חייבת להופיע תחת Networks (אותה רשת משנה מותרת אוטומטית).
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 גם כאשר מוגדר smart host גלובלי. false עבור דומיינים של שותפים בודדים שאסור להם לעבור דרך שער הגישה. אם לנתיב יש מאארח יעד, המתג מוזנח.
nextxch: Vertrauenswürdige Gateways (#pSpam · trustedRelayCidrs) כתובות IP או רשתות CIDR של שערי גישה עליונים. כאשר חיבור מגיע משם, nextxch לוקח את ה-IP של השולח ואת ה-HELO מכותרת ה-Received העליונה ביותר שלא נכתבה על ידי שער ברשימה או localhost. leer Add the public and internal gateway IP, e.g. 203.0.113.25 and 10.0.0.25. Only your own gateways: Received headers from listed IPs are taken as true. The spam analyzer then shows the rule TRUSTED_RELAY with the detected sender IP.
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, רק השער רשאי להגיע אל nextxch ביציאה 25. offen für alle בחומה האש (Firewall) של המארח או ההיקף, יש לאפשר את פורט 25 אך ורק מכתובת 203.0.113.25 או מכתובת ה-IP של השער הפנימי. פורטים 465, 587, 993 ו-443 נשארים פתוחים עבור לקוחות.