iptables, use alternate connection based on source ip or port
Posted on 2011-10-26
I have a linux firewall setup with 4 NIC's.
eth0 - 192.168.42.254 (LAN)
eth1 - 126.96.36.199 (Ethernet wireless corporate connection)
eth2 - 188.8.131.52 (ADSL 2+) (ppp1)
eth3 - 333.333.333.333 (ADSL 2+) (ppp0)
Currently all traffic goes out through eth1, I have port forwards and other rules for inbound connections and they are working OK. But I'm trying to get all traffic from a couple of source IP's to use eth3 and be able to send all FTP (port 21) traffic out eth2.
I've tried using
iptables -t NAT -A POSTROUTING -s 192.168.42.100 -d 0.0.0.0 -p tcp -o eth3 -j MASQUERADE
I also tried quite a few other combinations, can't seem to get it working. I've tried using good old Google to find an answer, but can't.
Is it possible to do this with iptables?
If so, what should I be using?
If Not, what other solution is available?