Last active
May 20, 2019 09:03
-
-
Save lemonlatte/dd84396050e62d4b129bc9ac8e239531 to your computer and use it in GitHub Desktop.
Use iptables to relay a mail server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sysctl -w net.ipv4.ip_forward=1 | |
iptables -t nat -R PREROUTING 1 -p tcp --dport 2587 -j DNAT --to-destination $(host my.mail.server | cut -f4 -d' '):25 | |
if [ $? -ne 0 ]; then | |
iptables -t nat -A PREROUTING -p tcp --dport 2587 -j DNAT --to-destination $(host my.mail.server | cut -f4 -d' '):25 | |
iptables -t nat -A POSTROUTING -j MASQUERADE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment