How to set up system wide proxy for Ubuntu 14.04 LTS? (Pls read details)

2

1

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.

v1h5

Posted 2015-12-24T09:24:01.713

Reputation: 121

1

This answer may guide you: http://askubuntu.com/questions/482126/system-wide-proxy-settings-when-on-a-windows-network-with-a-password. Be warned, though, there are some things that cannot go through a proxy.

– Kinnectus – 2015-12-24T09:35:55.257

Answers

2

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:

nKn

Posted 2015-12-24T09:24:01.713

Reputation: 4 960

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 127.0.0.1) solve this problem?

I played around earlier with iptables and this allocating tables thing but messed up badly, so should I go ahead with 127.0.0.1 in --to-destination parameter ? – v1h5 – 2015-12-26T14:55:06.320

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 – 2015-12-26T16:22:01.303

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 – 2015-12-28T04:55:08.077

0

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 8.8.8.8).

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.

Himanshu Shekhar

Posted 2015-12-24T09:24:01.713

Reputation: 780