19

My Internet access is through a proxy, my OS is Debian 8, each application must configure it to use the proxy, but there are some that are a headache to make it work with a proxy, then my question is: is there any way or a program to send all my connections(tcp, udp, etc.) to the proxy? that is to say, how do I set systemwide connection over a proxy server?

4 Answers 4

18

There are various solutions for this:

1. Configuring http_proxy variables

You can set $http_proxy and other such variables. Most applications will pick this variable automatically. To set it system-wide, you can set this variable in either your ~/.bashrc file or /etc/profile. Set it as:

http_proxy=http://user:password@proxyserver.com:3128
https_proxy=https://user:password@proxyserver.com:3128
export http_proxy
export https_proxy

2. Using proxy_chains

Some applications would not use your proxy variable and they might not even have settings to use a proxy server. In such a case, you can direct all your PC traffic through a proxy server by using proxy_chains.

I've never used proxy_chains, however their homepage seems to tell it all in one single page: http://proxychains.sourceforge.net/howto.html

3. Using transparent proxy

To force all your PC connection through a proxy, you can also use transparent proxy as an alternative to proxy_chains. I don't have much idea how to set this up (I did this a long time back though and it worked!) so you'll have to look on your own.

2
  • 1
    proxychains works flawlessly on FreeBSD, it is awesome. Oct 16, 2017 at 22:29
  • 1
    Is there a way to do this without plaintexting the password?
    – samthebest
    Jun 27, 2018 at 9:06
2

To setup the proxy environment variable as a global variable, open /etc/profile file:

# vi /etc/profile

Add the following information:

export http_proxy=http://proxy-server.mycorp.com:3128/

OR

export http_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/
2

You can set proxy in settings preference and it will reflect everywhere

enter image description here

3
  • 2
    What is the impact of this concretely? What variables / settings are edited? I would like to write a script that does this instead of doing it with the UI.
    – Guillermo
    Apr 4, 2020 at 23:37
  • @Guillermo According to the available input boxes, I would suppose it is modifying *_proxy environmental variables every other answer (for now) has referred to.
    – InQβ
    Jun 18, 2020 at 5:34
  • on dconf system like ubuntu 20.04 this is using the gsettings client for modifying the settings database of gnome.
    – Jan
    Apr 29, 2021 at 7:42
1

As shivams said there are various solutions for this.Just by exporting http_proxy you can't setup the connection. The way I will do setup the proxy will be as below,

  1. First I will setup the authentication by running the cntlm.

    a. To do that edit the /etc/cntlm.conf file by adding your username, password(you can also use hash generated for your password), domain, workstation and the proxy etc...

    b. And I will listen to the port 3128.

  2. I will setup the proxy for different applications or programs like for wget I will setup inside /etc/wgetrc, if it is curl then in curlrc etc...

  3. I will export the http(s)_proxy with http://localhost:3128.You can set this environment variable for a particular session or you can set it putting it inside /etc/profile.d/
  4. Done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .