I can set a proxy in browser and access internet. But I want a system wide proxy, such that every request that generates from my machine (Ubuntu 14.04 LTS) should pass through that proxy. If we set browser proxy, the requests generated from that particular browser will only pass through proxy but the requests generated from other source won't pass through proxy (For example, doing a ping to some some url).

I found few old questions which were related to modifying some config files in ubuntu, but I seriously they don't give any pointers to my question. How to set proxy in such a way that every (even the smallest) request pass through proxy and then touches internet ? TIA.


What you mean is configuring the so called transparent proxy. This ensures that any traffic sent from a machine will be routed to a different machine (a gateway) which will process the request.

To route any outgoing traffic to a different machine you'll need to play around with iptables. This should do that:

iptables -t nat -A OUTPUT -p tcp -j DNAT --to-destination 192.168.1.x

This is the easy part, the difficult one comes on the other side (the machine which will act as a gateway).

These links should guide you, though:

| improve this answer | |
  • Thank you for a good explanation. I get your point but I don't want to re-route the traffic to different machine but this should happen internally in my machine itself. Will including local address (say solve this problem? I played around earlier with iptables and this allocating tables thing but messed up badly, so should I go ahead with in --to-destination parameter ? – v1h5 Dec 26 '15 at 14:55
  • Well, you can configure the proxy on the same machine that originates the request and then play around with iptables so the request gets routed to the proxy, but I wonder why you want to do it that way? Usually one sets up a proxy to route all the traffic through it (and usually it's an independent machine), do you want to do some kind of HTTP URL blocker? – nKn Dec 26 '15 at 16:22
  • In the era of hacking and security, we never know what is being sent to internet from our machine. May the sending agent can be a normal applet on our machine or something else. You will agree with me when I say that there are several processes running in background of our machine and we actually don't know what they are doing. My question is completely based out of curiosity. I just want to see what my machine is doing/contacting when I am flying on internet. We can talk more on the idea if you are interested. If yes, lemme know your id. :) – v1h5 Dec 28 '15 at 4:55

You could open the Network Settings and enter the proxy details and then apply it system-wide. Network Manager applet is available right there in the Settings, or could easily come after typing "proxy" in Search for Applications.

The browser proxy, or any such configuration is limited to the browser/application, and does not affect how other applications connect to the network. So, in your case, proxy was set for the browser, but terminal is not a part of the browser and so doesn't have any proxy settings configured. The above method is graphical one, easy and would do the work. You can enter the DNS manually if any DNS related errors come up (use Google Public DNS

The only problem that comes with the simple method is no authentication details are entered in case you are using an authenticated proxy. You can set the proxy and work on the browser without any problem. Only problem would come in the Software Center for which you have to tweak around the APT configuration files. A Google Search for "how to set proxy settings for apt" would help you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.