SMTP Firewall/Gateway mit iptables
Jüngst hatte ich das Vergnügen, einen internen Mail-Server ohne gigantische Konfigurations- oder Designänderungen über eine statische IP ans Netz anzubinden. Das Gateway spielt eine Linux-Kiste mit Postfix als SMTP-Relayer. Mit ein bisschen iptables-Magie kann man den Traffic für SMTP, Submission und IMAP bequem ins interne Netz weiterleiten:
1 2 3 4 5 6 7 8 9 10 11 12 |
# IPv4 Forwarding aktivieren sysctl -w net.ipv4.ip_forward=1 # SMTP Redirect iptables -t nat -A PREROUTING -p tcp --dport 25 -j DNAT --to-destination <private IP>:25 # Submission Redirect iptables -t nat -A PREROUTING -p tcp --dport 587 -j DNAT --to-destination <private IP>:587 # IMAP Redirect iptables -t nat -A PREROUTING -p tcp --dport 143 -j DNAT --to-destination <private IP>:143 # Den Weg zurück ermöglichen iptables -t nat -A POSTROUTING -j MASQUERADE # Lokalen Mailer Daemon das Versenden ermöglichen iptables -t nat -A OUTPUT -p tcp --dport 25 -d <public IP> -j DNAT --to-destination <private IP>:25 |
Tweet