That is policy routing. Is it a SNATed firewall? I use below script for a SNATed firewall where I have two links such as a Leasedline and a ADSL. I route web traffic (both HTTP and HTTPS -- port tcp 80 and tcp 443) via ADSL link.
YOU want to route mail and icq (tcp110, tcp25, tcp5190) through eth1. pls change your ports accordinly.
Pls replace
gatewayipofprovider1,
gatewayipofprovider2,
ipofETH1 and
ipofETH2 with yours.
by default, My firewall also routes trafic via eth2 (i.e-
gatewayipofprovider1--- Leasedline or realiplink ) I route http and https traffic via eth1 (i.e-
gatewayipofprovider2 --ADSL or adsllink
) .in your case, it is the SAME.
below is the Script.
echo 210 realiplink >> /etc/iproute2/rt_tables
echo 211 adsllink >> /etc/iproute2/rt_tables
ip route add
gatewayipofprovider1 dev eth2 table realiplink
ip route add default via
gatewayipofprovider1 dev eth2 table realiplink
ip route add
gatewayipofprovider2 dev eth1 table adsllink
ip route add default via
gatewayipofprovider2 dev eth1 table adsllink
iptables -t mangle -A OUTPUT -p tcp -m multiport --dports 80,443 -j MARK --set-mark 1
ip rule add fwmark 1 pri 100 table adsllink
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source
ipofETH1
echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
ip rule add from ipofETH2 pri 200 table realiplink
ip rule add from ipofETH1
pri 300 table adsllink
Then, issue below command to see routing tables
ip rule list
PLS NOTE:
In the above script, I have marked OUTPUT trafic as 1. below is the command I have given
iptables -t mangle -A OUTPUT -p tcp -m multiport --dports 80,443 -j MARK --set-mark 1
the reason for that is the firewall is itself is a SQUID proxy server. But not a TRANSPARENT PROXY.
Just acts as a normal proxy. (i.e- I have configured client browsers with ip address and port 3128.)
Try with the above script and see if it works.
UNLESS it works, pls replace the above command with this.
iptables -t mangle -A PREROUTING -p tcp -m multiport --dports 80,443 -j MARK --set-mark 1
or
iptables -t mangle -A PREROUTING -i eth0 -p tcp -m multiport --dports 80,443 -j MARK --set-mark 1