Routing smtp and pop3 past iptables through proxy

listed in answer

Routing smtp and pop3 past iptables through proxy
0 votes, 0.00 avg. rating (0% score)

ANSWER:

You can use either a SOCKS proxy server for this or you can use iptables to enable NAT. I assume that your client host is within a local network and uses private IP addresses such as 10.0.0.0/8, 172.28.0.0/12 or 192.168.0.0/16.

Pre conditions: you can reach your client host from your Linux box and you can reach the Internet/Interwebs.

So first step is to enable IP forwarding:

# set kernel flag to allow IP forwarding from one to another network device
echo 1 > /proc/sys/net/ipv4/ip_forward

Next step is to use iptables to activate NAT:

# enable NAT for Internet device (here eth0)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# accept incoming Internet traffic, which is related to established outgoing connection
iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT

# enable forwarding from internal device eth1 to external device eth0
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

That’s a really simple setup and I recommend to take a closer look into iptables to provide security to your LAN as well as access for your LAN to the Internet.

by Jens Bradler from http://serverfault.com/questions/382509