19

Someone's set up a proxy on my machine and I want to know what it is. Is there a way to find the proxy server using the command line and not the GUI?

TheWanderer
  • 19,395
  • 12
  • 50
  • 65

5 Answers5

20

For any system-wide proxy for HTTP, you can check the value of http_proxy environment variable:

echo "$http_proxy"

For HTTPS:

echo "$https_proxy"

Similarly, there are ftp_proxy, socks_proxy for serving the exact purpose of their names. There is also all_proxy for setting proxy for all these protocols at once. Just to note, no_proxy unsets proxy for any specific addresses of any (or all) given protocol. Just for sake of completeness, you might want to check the uppercase version of these variables too, although the lowercases are standard for *_proxy environment variables (only environment variables i am aware of that are lowercased).

Note that, these will show any system-wide proxy setting, not application-specific. For example, firefox, or apt can have their own proxy settings irrespective of any global one. Some applications do not honor these variables too (e.g. specific gnome apps use gsettings), so YMMV.

heemayl
  • 91,753
12

Attempt an http connection to the outside:

wget http://google.com

You'll see something like this as a result:

--2017-06-12 13:02:53--  http://google.com/
Resolving google.com (google.com)... 172.217.11.142, 2607:f8b0:4002:810::200e
Connecting to google.com (google.com)|172.217.11.142|:80... connected.
HTTP request sent, awaiting response... 302 authenticationrequired
Location: http://192.168.254.99:9090/mwg-internal/de5fs23hu73ds/plugin?target=Auth&reason=Auth&ClientID=3130909038&ttl=600&url=aHR0cDovL2dvb2dsZS5jb20v&rnd=1497286973 [following]
--2017-06-12 13:02:53--  http://192.168.254.99:9090/mwg-internal/de5fs23hu73ds/plugin?target=Auth&reason=Auth&ClientID=3130909038&ttl=600&url=aHR0cDovL2dvb2dsZS5jb20v&rnd=1497286973
Connecting to 192.168.254.99:9090... connected.
HTTP request sent, awaiting response... 401 authenticationrequired

Your proxy server in this case is found after the 302 authentication required. http://192.168.254.99:9090/

wjandrea
  • 14,236
  • 4
  • 48
  • 98
wilsotc
  • 221
10

In Linux, you can use this to check the proxies defined in the system

env | grep proxy
5

check the file :

cat /etc/apt/apt.conf
cat /etc/environment

To Modify contents of file (remove everything from apt.conf for no proxy and only proxy sentences from environment)!

sudo nano /etc/apt/apt.conf
sudo nano /etc/environment
minigeek
  • 1,071
  • gedit is a GUI program. How does this avoid using the GUI? – TheWanderer Sep 29 '16 at 17:38
  • use cat then @Zacharee1.. i said gedit so OP can also edit it. – minigeek Sep 29 '16 at 17:40
  • gedit might not even be installed, as this could be a server installation. nano and vim are both command line text editors. – TheWanderer Sep 29 '16 at 17:41
  • @Zacharee1 hmm ..they r universal.I will edit solution thanx – minigeek Sep 29 '16 at 17:42
  • Also, the first path doesn't actually exist on my system, and the second only includes a PATH variable. – TheWanderer Sep 29 '16 at 17:44
  • @Zanna i edited – minigeek Sep 29 '16 at 17:46
  • 1
    Removing everything in /etc/environment will break PATH and possibly other configurations. Please don't do that. – TheWanderer Sep 29 '16 at 17:46
  • @Zacharee1 again edited..sry for mistakes – minigeek Sep 29 '16 at 17:49
  • You should also explain what to look for. apt.conf doesn't exist on my system (and actually needs to be manually created to fix apt-get through a proxy), and I wouldn't know what to look for in environment. – TheWanderer Sep 29 '16 at 17:50
  • @Zacharee1 unity containts/created apt.conf file when proxy is applied through network settings where as other system has a folder apt.conf.d (i dont know much about it detail) but i set the proxy settings for terminal through that environment has files like http_proxy=.....!! – minigeek Sep 29 '16 at 17:53
2
# netstat -na

OR, if you think/guess any proxy server then grep it to confirm, e.g.

# netstat -na |grep <ProxyGuess IP>
Melebius
  • 11,431
  • 9
  • 52
  • 78
  • these your answer does not tell what to look for exactly in the first half. and it does not answer the central part of the question of "i want to know what it is" because you are assuming something central must already know in order to get the answer. – Alexander Stohr Mar 04 '22 at 07:46