ive local server with squid to manage my lan , it got 2 NICs and my mail server its outside the lan what i need here when users ty to connect and send email through NIC-1 its should fwd request to NIC2 which is connected to internet ( port 25,110 ) any tips to fwd by iptables regards
1 Answer
Assuming that eth0
is the internal interface and eth1
is the external interface.
Enable IP forwarding:
echo 1 > /proc/sys/net/ipv4/ip_forward
and try something like this:
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 25 -j DNAT --to-destination <eth1_IP>:25
iptables -A FORWARD -i eth0 -p tcp --dport 25 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
Do the same for port 110.