How To Check Proxy In Linux

Find Proxy Server using Command Line – Ask Ubuntu

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?
TheWanderer18. 8k12 gold badges47 silver badges63 bronze badges
asked Sep 29 ’16 at 17:01
3
For any system-wide proxy for HTTP, you can check the value of _proxy environment variable:
echo “$_proxy”
For HTTPS:
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.
answered Sep 29 ’16 at 17:19
heemaylheemayl84k17 gold badges184 silver badges255 bronze badges
2
Attempt an connection to the outside:
wget
You’ll see something like this as a result:
–2017-06-12 13:02:53– Resolving ()… 172. 217. 11. 142, 2607:f8b0:4002:810::200e
Connecting to ()|172. 142|:80… connected.
HTTP request sent, awaiting response… 302 authenticationrequired
Location: [following]
–2017-06-12 13:02:53– Connecting to 192. 168. 254. 99:9090… 401 authenticationrequired
Your proxy server in this case is found after the 302 authentication required.
wjandrea12. 7k4 gold badges41 silver badges86 bronze badges
answered Jun 12 ’17 at 17:04
wilsotcwilsotc2012 silver badges3 bronze badges
In Linux, you can use this to check the proxies defined in the system
env | grep proxy
answered Feb 9 ’18 at 2:23
Kristada673Kristada6734814 silver badges17 bronze badges
1
check the file:
cat /etc/apt/
cat /etc/environment
To Modify contents of file (remove everything from for no proxy and only proxy sentences from environment)!
sudo nano /etc/apt/
sudo nano /etc/environment
answered Sep 29 ’16 at 17:22
minigeekminigeek1, 0137 silver badges13 bronze badges
10
# netstat -na
OR, if you think/guess any proxy server then grep it to confirm,
e. g.
# netstat -na |grep
Melebius10. 1k7 gold badges42 silver badges69 bronze badges
answered Feb 8 ’18 at 8:48
Not the answer you’re looking for? Browse other questions tagged command-line proxy or ask your own question.
Linux Proxy Server Settings - Set Proxy For Command Line

Linux Proxy Server Settings – Set Proxy For Command Line

To use a proxy on the Linux command-line, you can set the environment variables _proxy, _proxy or ftp_proxy, depending on the traffic type.
These proxy server settings are used by the almost all Linux command-line utilities, e. g. ftp, wget, curl, ssh, apt-get, yum and others.
If you don’t know yet which proxy server to use, you can take one from the lists of the free public proxy servers at the end of this article.
Cool Tip: Need to improve security of the Linux system? Encrypt DNS traffic and get the protection from DNS spoofing! Read more →
Export Proxy Server Settings
Set these variables to configure Linux proxy server settings for the command-line tools:
$ export _proxy=”PROXY_SERVER:PORT”
$ export ftp_proxy=”PROXY_SERVER:PORT”
If a proxy server requires authentication, set the proxy variables as follows:
$ export _proxy=”USER:PASSWORD@PROXY_SERVER:PORT”
$ export ftp_proxy=”USER:PASSWORD@PROXY_SERVER:PORT”
Special Characters: If your password contains special characters, you must replace them with ASCII codes, for example the at sign @ must be replaced by the%40 code, e. p@ssword = p%40ssword.
Test The Proxy Server From The Linux Command-Line
As only you have configured a proxy it is time to ensure that it works as expected.
First off all it is required to check that the proxy server settings are set in the corresponding proxy variables.
Than it is required to ensure that your public IP address has changed.
Also it would be interesting to measure and compare response time of the remote resources and the Internet speed with and without proxy.
Check the current proxy server settings:
$ env | grep -i proxy
Check your public IP address from the Linux command-line:
$ wget -q -O – \
| sed -e ‘s/. *Current IP Address: //’ -e ‘s/<. *$//' Compare the difference in the response time with the configured proxy and without it: $ time wget -q -O - \ Check the Internet download speed through the proxy: $ wget --output-document=\ /dev/null Unset Linux Proxy Variables Use the following commands to disable proxy: $ unset _proxy $ unset ftp_proxy Cool Tip: Stay anonymous during port scanning! Use Nmap + Tor + ProxyChains! Safe and easy penetration testing! Read more → Automate Proxy Server Settings In Linux If you use the same proxy server settings for the, and ftp traffic, you can use the following commands to set and unset the proxy settings: $ export {,, ftp}_proxy="PROXY_SERVER:PORT" $ unset {,, ftp}_proxy If you use a proxy server often, you can create Bash functions as follows (add to your ~/ file): # Set Proxy function setproxy() { export {,, ftp}_proxy="PROXY_SERVER:PORT"} # Unset Proxy function unsetproxy() { unset {,, ftp}_proxy} Reload your ~/ file. $ source ~/ Now use the setproxy and unsetproxy commands to set and unset Linux proxy server settings. Lists of Free Public Proxy Servers WARNING: Free public proxy servers can insert your IP address into the headers of requests or sniff your traffic! Don’t use them to transfer sensitive data and do not expect anonymity! Hide My Ass Proxy Server List Anonymous Public Proxy Servers Daily HTTP Proxies Cool Tip: Even if you use proxy server, all your DNS queries still go to the name servers of your ISP (Internet Service Provider)! Improve anonymity, by using free public name servers! Read more → How to check if Network Proxy is really applied? - Ask Ubuntu

How to check if Network Proxy is really applied? – Ask Ubuntu

I’m trying to set Network Proxy to use my LAN’s internet connection to update packages.
while the proxy settings works on my firefox, but the package manager still cannot connect to Internet. I have set proxy in System >> Preferences >> Network Proxy and I have entered the user/pass for the proxy in ‘Details’ too.
How can I make sure that the Proxy Network is applied correctly?
Luis Alvarado197k157 gold badges524 silver badges691 bronze badges
asked Sep 7 ’10 at 14:32
First of all make sure you click on “Apply system-wide… ” whenever you change proxy settings in the gnome-network-properties (System -> Preferences -> Network Proxy). This sets _proxy and related environment variables. This should be available to all programs started after the proxy setting is “Applied system-wide… “. To be really sure, you can logout and back-in to double-check this.
If you open a terminal and use the command set | grep -i proxy you would see the relevant environment variables set. Ideally this should be enough.
However, I have faced situations where all the above still doesn’t work: Synaptic or apt-get (over commandline) can’t connect to the internet through the proxy even after it is set in the above way. In such cases, one solution is to add a file in /etc/apt/ with specific proxy configuration for apt (this will be used by apt-get, aptitude, synaptic and Ubuntu software center).
Follow the below steps:
Create /etc/apt/
gksudo gedit /etc/apt/
Put the following contents into it – modify the contents to suit your situation.
Acquire::::Proxy “;
If you have a user-name & password you could encode the same in the proxy url (like so, ) or you can use something like ntlmaps for better control.
More info could be found here.
answered Sep 7 ’10 at 14:49
koushikkoushik4, 8044 gold badges24 silver badges35 bronze badges
3
Have you clicked the Apply System Wide (highlighted) button? If you don’t proxy settings are local to your Gnome session and therefore when root goes off to download packages, it won’t use the same network settings.
answered Sep 7 ’10 at 14:53
Oli♦Oli273k106 gold badges641 silver badges810 bronze badges
1
There’s a bunch of good answers above that will help you if you’re having problems (which is what your question implies). However, this is an answer to the narrow question of checking whether the Network proxy settings have been applied:
Method 1:
Start a new shell (xterm), then check the environment variables:% env | grep -i proxy
_proxy=ftp_proxy=all_proxy=socks172. 17. 0. 130:8080/…
Note that existing shells will not have updated environment variables. So if you’re executing a command that looks at environment variables for its proxy settings, start it in a shell created after the changes to the proxy settings.
Method 2:
Use gconftool to query the gconf settings (which are stored under ~/):% gconftool -R /system/proxy
old_ftp_port = 0
old_ftp_host =
old_secure_port = 0
old_secure_host =
autoconfig_url =
mode = manual
ftp_host = 172. 130
secure_host = 172. 130… % gconftool -R /system/_proxy
use_authentication = false
authentication_password =
authentication_user =
ignore_hosts = [localhost, 127. 0/8, *,… ]
use__proxy = true
port = 8080
use_same_proxy = true
host = 172. 130
As others have noted, be sure that your browser and other apps are set to “Use System Proxy Settings”.
answered Jan 30 ’12 at 22:47
craigstercraigster611 silver badge1 bronze badge
If you try:
curl
from the command line, then if you get HTML back the proxy is working.
answered Jul 17 ’15 at 14:18
To set a proxy temporarily you can fire up a terminal and enter
export _proxy=”yourproxy:yourport”
Then start the program, e. g. Synaptic for package management. The console might give you helpful output on what goes wrong.
dv3500ea35. 2k13 gold badges96 silver badges150 bronze badges
answered Sep 9 ’10 at 23:15
PhiPhi1631 silver badge6 bronze badges
I’m using a proxy also, and I had to set the proxy settings specifically for Synergy and update manager (using Synergy: Configuration->Preferences->Network). There’s no option there to use the “system settings”, and even if it should work, changing the proxy server at the system level never made me able to update:-(
I’m interested in a solution that make it work though:-)
answered Sep 7 ’10 at 15:18
Little JawaLittle Jawa2, 5632 gold badges18 silver badges25 bronze badges
anyone thought to check/add settings to:
/etc/environment
try it with:
_proxy=”user:password@proxyserver:port”
ftp_proxy=”user:password@proxyserver:port”
answered Aug 29 ’11 at 20:55
t0m5k1t0m5k1811 silver badge2 bronze badges
Click on “Apply System-Wide… ” and check that all your internet applications are set to use the system proxy. There’s nothing more to it than this. There’s no need to tamper with configuration files and start-up scripts.
answered Sep 9 ’10 at 8:17
Applying system-wide is not enough! I think maybe ISA Server or maybe synaptic reset connection for each query to the web this issue that login and password authentication lie down. Or maybe ISA Server do not accept to transmit query that do not answer on HTTP protocol, but It’s not my favorite.
answered May 26 ’11 at 16:04
Not the answer you’re looking for? Browse other questions tagged networking package-management proxy or ask your own question.

Frequently Asked Questions about how to check proxy in linux

How do you check proxy is enabled in Linux?

Method 1: Start a new shell (xterm), then check the environment variables: % env | grep -i proxy http_proxy=http://172.17.0.130:8080/ ftp_proxy=ftp://172.17.0.130:8080/ all_proxy=socks://172.17.0.130:8080/ … Note that existing shells will not have updated environment variables.Sep 7, 2010

How do I check my proxy?

In any Windows version, you can find the proxy settings via the Control Panel on your computer.Click on Start and open the Control Panel. Then click on Internet Options.In the Internet Options, go to Connections > LAN settings.Here you have all the settings that are related to setting up a proxy in Windows.

Where are proxy settings in Linux?

You configure global HTTP and HTTPS proxies in the /etc/profile. d/ directory of Cumulus Linux. To do so, set the http_proxy and https_proxy variables, which tells the switch the address of the proxy server to use to fetch URLs on the command line.

Leave a Reply

Your email address will not be published. Required fields are marked *