Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want to have GNOME applications (as well as Firefox and Chrome) access the network through a proxy, I need only use gnome-network-properties (a nice and simple GUI I must say). For other apps (e.g. APT, Transmission, XChat), I have to use their specific ways of doing it.

Is there a way to avoid this, something I can turn on and off when in a network that requires a proxy (hostname:port)?

share|improve this question
I think that the http_proxy variable is what you're looking for. Take a look in the Proxy Support howto. – ierax Mar 18 '11 at 8:28

I think pretty much all linux/unix software that uses networking will honor the http_proxy and ftp_proxy environment variables. Depending on how your distribution is set up, /etc/environment will exist and be read by default by login shells.

You can add a line saying


in /etc/environment easily enough, but changes in that file will only take hold the next time you start a shell process -- and only in that shell process. I don't think you can modify global variables in a shell other than your current one.

share|improve this answer

I agree that the best way to use the proxy server is with the environment variable http_proxy, as other answers have pointed out. Unfortunately, not all applications honour the http_proxy environment variable, which is why I still use tsocks for some programs to use LD_PRELOAD to force network connections to go through a SOCKS proxy.

share|improve this answer

There's no one-for-all solution. Each program uses its own way to connect to a proxy server.

I have a similar problem at my office. I found that best way to do this is to use a VPN connection. When you connect, the whole system network traffic will go through the VPN. If you don't have access to a VPN server, you can run a new one manually, and connect it to the proxy server you've got.

If you have an application that doesn't support proxy, you can use something like socksify, to wrap its network connection.

share|improve this answer
So you've tried this and failed? – Tshepang Mar 18 '11 at 11:02

Yeah! There are many ways to do things. I made a tool to simplify the entire task, as I sometime had the same problem.
They are just shell scripts. You can download from here.

share|improve this answer

Besides tsocks — which still AFAICT requires you to launch programs with the correct environment to work — you should check out tun2socks. With it you set up a TUN interface (i.e. a new network interface, just like a VPN would create) and any packets sent there get proxied to your SOCKS5 server. You then set up your system routes to actually send the traffic to this. Seems like a nice approach.

(I also found redsocks via this post. This doesn't seem as elegant as using a TUN interface to me — e.g. it doesn't really handle UDP at all, for starters.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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