Mail Server Presets
Docker Host-Network vs Bridge Mode for Real SMTP Client IPs
Preserve authentic external SMTP sender IPs for SPF, RBL, and fail2ban checks by running Stalwart with host networking or HAProxy PROXY protocol.
Zero Docker NAT Spoofing · Real IPv4/IPv6 · SPF Accurate
The Docker Bridge NAT Trap on Mail Servers
Running a mail server behind standard Docker userland proxy NAT rewrites incoming IPv4 and IPv6 source addresses to the internal bridge gateway. Every inbound spammer then appears to come from 172.18.0.1, bypassing DNSBLs and distorting SPF checks.
Fixing Source IPs With Host Networking or Native Binary
Set network_mode: host in Docker Compose or install Stalwart directly as a systemd service under a dedicated unprivileged stalwart-mail user with ambient CAP_NET_BIND_SERVICE.
Measured Thresholds & Stalwart Configuration Parameters
| Container Network Mode | Inbound Client IP Visibility | SPF / RBL Impact |
|---|---|---|
| Bridge NAT (Default Docker) | Sees 172.17.0.1 gateway IP | Breaks SPF, DNSBL, and rate limiting completely |
| network_mode: host | Sees genuine external IPv4/IPv6 | Recommended single-node setup for Vultr & InterServer |
| PROXY Protocol v2 | Preserves IP behind load balancer | Required only when fronted by external TCP proxy |
| Systemd Binary Install | Direct host sockets (no Docker) | Lowest overhead; binds ports 25, 465, 993, 443 cleanly |