Miłosz
Miłosz

Reputation: 3

netsh winhttp set proxy vs using GUI windows proxy settings

I have an issue when configuring a proxy server connection.

Installed Squid Proxy (http://www.squid-cache.org/) on my Virtual Machine using VirtualBox. VM - Ubuntu 22.04 LTS
Network Adapter - Bridged Adapter

On my local machine (Windows 11 Pro Version 10.0.22621 Build 22621) for test purposes, I have created a firewall rule to restrict access to XYZ page. Once the rule has been enabled the page is not accessible from my machine.

First scenario (Succesful one) I connect to the Proxy server I have created on my VM using the Windows GUI. Settings > Network & Internet > Manual Proxy Setup > Use a Proxy Server
I provide IP address of my VM machine and the default Squid port (3128). Once I connect to the Proxy server I check if I'm able to connect to XYZ page from now on. Ends up as a success. Squid logs show that the request went through the server. Everything is working.

Second scenario (Unsuccessful one) Local machine is not connected to the proxy server. I try to connect, but this time I am using the netsh.exe
netsh winhttp set proxy serveraddress:port (but with the actual values :))
I check if I'm able to connect to XYZ page from now on. Page XYZ is still blocked. Checking proxy logs. No request went through that server.

What might be the issue?

My workaround for now was to use the GUI settings, but was just curious why it was not working using the netsh command. I was wondering if there is something I have missed in netsh winhttp documentation page.

Upvotes: 0

Views: 1537

Answers (1)

Denham
Denham

Reputation: 13

The "netsh winhttp set proxy" command is mostly depreciated.

If you need to set the proxy using the command line it should be done using the "netsh winhttp set advproxy"

set advproxy setting-scope=machine settings={<settings>}

set advproxy setting-scope=machine settings={\"Proxy\":\"contoso-proxy.com:3128\",\"ProxyBypass\":\"\",\"AutoconfigUrl\":\"\",\"AutoDetect\":true}

Or using a JSON settings file

set advproxy setting-scope=user settings-file=settings.json

Where the settings.json contains the information

  {
  "ProxyIsEnabled": true,
  "Proxy": "http=http-proxy.com:8080;https=https-proxy.com:8081;ftp=ftp-proxy.com:8082;socks=socks-proxy.com:8083",
  "AutoConfigIsEnabled": false,
  "AutoDetect": true,
  "PerUserProxySettings": true
  }

You can see more information about this on the Microsoft site for Netsh. https://learn.microsoft.com/windows/win32/winhttp/netsh-exe-commands

Upvotes: 0

Related Questions