This cannot be done easily with iptables; Let me give you some insight. A transparent proxy sits between the user and the internet, and intercepts all packets which is being routed through it. For this to work (in a normal scenario), the transparent proxy looks at the source and the destination address, and does all the steps required to open the connection.
Now, let me tell you why iptables is not such a good choice for your requirements.
- DNAT (changing the destination IP) is a bad idea, because the transparent proxy would not know anymore which destination the packet was meant for.
- MASQUERADE is useless in this case, because this is a target to hide source subnets which the destination network has no route to (usually done at a home router to hide the private subnets from the internet)
- SNAT would be even worse, because changing the source IP would result in the gateway sending back replies to the wrong ip...
What you really need is to dynamically change the gateway for the traffic you selected. Dynamic routing is a complicated topic, which I will not cover here.
Maybe you should rethink about changing the default gateway, this would be the easiest solution... Or, place two routes like this:
route add -net 0.0.0.0/1 gw <squid_ip>
route add -net 128.0.0.0/1 gw <squid_ip>
That way, your default gateway remains in place, even though not used anymore.
But after deleting those two routes, your default gateway is back in business...