Skip to main content

Ingress Option 1: Direct DNS Round-Robin (No Front Proxy)

Every backend hermEX pod (Pod 0, Pod 1, Pod N) runs the full proxy-capable stack (gateway, imap, pop3, sieve, mta). When a user or remote SMTP sender connects to any pod, that pod reads users.homeserver and domains.homeserver from MariaDB and proxies traffic transparently to the owning pod. Because of that design, small and medium clusters can expose backend pods directly via DNS Round-Robin without deploying any separate front-end load balancer.

When you need automated millisecond health eviction without waiting on client DNS caching, add Stateless Edge Proxy Nodes or a dedicated L4 TCP Load Balancer in front.


1. Architecture Overview​

Internet / Mail Clients / Remote MTAs
DNS returns A = [203.0.113.10, 203.0.113.11, 203.0.113.12]
MX returns priority 10 -> mx0, mx1, mx2
| |
v v
+---------------------+ +---------------------+
| Pod 0 (node_id: 0) | | Pod 1 (node_id: 1) |
| Public 203.0.113.10 | | Public 203.0.113.11 |
| Private 10.0.0.10 | | Private 10.0.0.11 |
+----------+----------+ +----------+----------+
\ /
\ Pod Bridge (10.0.0) /
+--------------------+
| Shared MariaDB VIP |
+--------------------+

2. Complete DNS Record Matrix (2 or 3 Pods)​

The example below configures a 2-pod cluster hosting domain example.com:

  • Pod 0 (node_id: 0): public IP 203.0.113.10, private IP 10.0.0.10
  • Pod 1 (node_id: 1): public IP 203.0.113.11, private IP 10.0.0.11

Publish all records below at your DNS provider (keep TTL low, 60 to 300 seconds, so emergency DNS changes propagate quickly):

Infrastructure & Shared Mail Hostnames​

TypeNameValueTTLPurpose
Amx0203.0.113.10300Dedicated SMTP hostname for Pod 0 (must match mx0.example.com PTR)
Amx1203.0.113.11300Dedicated SMTP hostname for Pod 1 (must match mx1.example.com PTR)
Amail203.0.113.10120DNS round-robin target for Webmail, IMAP, POP3, Exchange, DAV
Amail203.0.113.11120DNS round-robin target 2 for mail.example.com
Aadmin203.0.113.10300Admin Panel endpoint (Pod 0 runs hermex-admin serve)
CNAMEautodiscovermail.example.com300Outlook / Exchange Autodiscover
CNAMEautoconfigmail.example.com300Thunderbird / generic Autoconfig
CNAMEmta-stsmail.example.com300MTA-STS HTTPS policy file host
Set every Cloudflare mail record to DNS only (gray cloud)

If you use Cloudflare DNS, disable proxying (orange cloud off, DNS only) on mx0, mx1, mail, admin, autodiscover, autoconfig, and mta-sts. Cloudflare orange-cloud proxy blocks SMTP (25, 465, 587), IMAP (143, 993), POP3 (110, 995), ManageSieve (4190), and TLS-ALPN-01 ACME verification.

Hosted Mail Domain Records (example.com)​

TypeNameValue / TargetPriorityPurpose
MX@mx0.example.com10Equal-weight inbound SMTP to Pod 0
MX@mx1.example.com10Equal-weight inbound SMTP to Pod 1 (MTAs automatically fail over to the live pod)
TXT@v=spf1 mx ip4:203.0.113.10 ip4:203.0.113.11 -alln/aAuthorizes every pod that runs outbound hermex-mta
TXThermex._domainkey(copy from hermex-admin dns-records example.com)n/aDKIM public key (shared across all pods via MariaDB + key_secret)
TXT_dmarcv=DMARC1; p=quarantine; rua=mailto:dmarc@example.comn/aDMARC enforcement and aggregate reporting
TXT_mta-stsv=STSv1; id=2026120601n/aMTA-STS version token
TXT_smtp._tlsv=TLSRPTv1; rua=https://mail.example.com/tlsrptn/aTLS-RPT reporting destination
SRV_imaps._tcp0 1 993 mail.example.com0Implicit-TLS IMAP discovery
SRV_submission._tcp0 1 587 mail.example.com0SMTP submission discovery
SRV_autodiscover._tcp0 1 443 mail.example.com0Exchange Autodiscover SRV
SRV_caldavs._tcp / _carddavs._tcp0 1 443 mail.example.com0CalDAV and CardDAV SSL service discovery

Reverse DNS (PTR) at Your VPS / Cloud Provider​

Configure one PTR record per pod public IP matching its MX / A identity:

  • 203.0.113.10 -> mx0.example.com (and set Pod 0 /etc/hermex/config.json "hostname": "mx0.example.com" or "mail.example.com" matching PTR)
  • 203.0.113.11 -> mx1.example.com
Include every pod's public IP in SPF and PTR

Outbound mail from any pod's hermex-mta worker connects using that pod's public IPv4 address. Remote receivers immediately check PTR (rDNS), EHLO banner hostname, and SPF. Missing ip4: entries or missing PTR records on Pod 1 will cause outbound mail from Pod 1 to fail SPF or land in spam.


3. Complete BIND 9 Zone Example​

If you self-host authoritative DNS on BIND 9 (named):

$ORIGIN example.com.
$TTL 300

@ IN SOA ns1.example.com. hostmaster.example.com. (
2026120601 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ) ; minimum

@ IN NS ns1.example.com.
@ IN NS ns2.example.com.

; Per-pod SMTP endpoints and MX targets
mx0 300 IN A 203.0.113.10
mx1 300 IN A 203.0.113.11
@ 300 IN MX 10 mx0.example.com.
@ 300 IN MX 10 mx1.example.com.

; Client protocol round-robin across both pods
mail 120 IN A 203.0.113.10
mail 120 IN A 203.0.113.11

; Admin host pinned to Pod 0 (runs hermex-admin serve)
admin 300 IN A 203.0.113.10

autodiscover 300 IN CNAME mail.example.com.
autoconfig 300 IN CNAME mail.example.com.
mta-sts 300 IN CNAME mail.example.com.

@ 300 IN TXT "v=spf1 mx ip4:203.0.113.10 ip4:203.0.113.11 -all"
_dmarc 300 IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"
_mta-sts 300 IN TXT "v=STSv1; id=2026120601"
_smtp._tls 300 IN TXT "v=TLSRPTv1; rua=https://mail.example.com/tlsrpt"

_imaps._tcp 300 IN SRV 0 1 993 mail.example.com.
_submission._tcp 300 IN SRV 0 1 587 mail.example.com.
_autodiscover._tcp 300 IN SRV 0 1 443 mail.example.com.
_caldavs._tcp 300 IN SRV 0 1 443 mail.example.com.
_carddavs._tcp 300 IN SRV 0 1 443 mail.example.com.

4. Shared ACME Certificates Across Pods​

When Pod 0 or Pod 1 renews Let's Encrypt TLS certificates for mail.example.com or customer domains via TLS-ALPN-01 (443) or HTTP-01 (80), hermEX encrypts the issued certificate and private key using key_secret and stores it in MariaDB. Both pods poll the database every 15 seconds, so clients hitting either 203.0.113.10 or 203.0.113.11 receive the exact same valid certificate without manual file copying.


5. Verification​

Confirm DNS round-robin returns both pod IPs and that TLS, IMAP, and SMTP answer cleanly on each IP independently:

# Confirm multiple A and MX records resolve
dig +short A mail.example.com
dig +short MX example.com

# Test HTTPS gateway TLS certificate on each pod directly
for ip in 203.0.113.10 203.0.113.11; do
echo "=== Pod $ip ==="
curl -sk --resolve mail.example.com:443:"$ip" https://mail.example.com/api/v1/branding
openssl s_client -connect "$ip":993 -servername mail.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -dates
done

# Run hermEX built-in DNS diagnostics (also checks multiple A/MX/SPF records)
sudo hermex-admin -config /etc/hermex/config.json check-dns example.com

When to Upgrade From DNS Round-Robin to a Load Balancer​

DNS Round-Robin works smoothly for SMTP (remote MTAs automatically try the other MX record) and for modern webmail browsers implementing Happy Eyeballs (RFC 8305). However, if one pod stops abruptly for maintenance or hardware failure, legacy desktop IMAP/POP3/ActiveSync clients that cache one IP from A mail.example.com can stall until their DNS TTL expires. When zero-stall pod failover is required, deploy Ingress Option 3: L4 TCP Load Balancer.