Is there any way to stop users from sending attachments over Gmail or any web based email including private mail servers, if internet access is through a Linux box running Ip Tables/Squid etc. We are looking for a free/open source tool. Can this be achieved through Squid or IPTables/Shorewall?
Not really, no.
Firstly, when the traffic in question is passing through your proxy server, it's just web traffic - it's not an email yet. So to just block attachments, your proxy would have to read the traffic in great detail, and understand how to tell when every sort of web mail is moving an attachment.
That would be difficult but possible, although it would be hard to be sure you were catching everything: but you also have to consider that Gmail and many other web email providers support https, which means the traffic might be encrypted as it goes through the proxy, and so you have no way of reading it.
A tad bit off topic but realted none the less. If the ultimate goal is to prevent malicious downloads and you are running a windows domain might I suggest using an ESR GPO to help mitigate the vulnerability.
And FYI there are ways to read the SSL encrypted web traffic despite the encryption, it just requires a little web proxy magic along with a GPO for trusted CA's.
If you are working with squid and would like to proxy ssl to get more fidelity on ssl encrypted email traffic start here..http://wiki.squid-cache.org/Features/SslBump (Make sure you include your lawyers when you write the policies if you decide to use this )
Disclaimer: do not expect squid to now block web based email attachments, this solution will just allow you to have more oversight of what is coming in and out of your network.