following setup:
Client(Outlook) <-----> |eth1 PROXY eth0 | <------> Interwebs
How do i manage to do this? Setting the standard policy of all filter tables to ACCEPT doesnt change a thing, so is prerouting the way to go?
Greets, Kai
following setup:
Client(Outlook) <-----> |eth1 PROXY eth0 | <------> Interwebs
How do i manage to do this? Setting the standard policy of all filter tables to ACCEPT doesnt change a thing, so is prerouting the way to go?
Greets, Kai
You can use either a SOCKS proxy server or iptables and NAT for this.
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:
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.
To limit access only to certain protocols (here SMTP, POP3, IMAP) you can use following setup:
# 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 --dport 25 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth1 --dport 110 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth1 --dport 143 -o eth0 -j ACCEPT