windows下控制台代理设置

PowerShell设置代理

  • 设置代理
1
netsh winhttp set proxy "127.0.0.1:1080"
  • 恢复默认
1
netsh winhttp reset proxy

注意要在管理员模式运行,不然提示权限不足。

命令行设置代理

  • 设置代理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#HTTP 代理设置:
set http_proxy=http://127.0.0.1:1080

set https_proxy=http://127.0.0.1:1080
# SOCKS5 代理设置:
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

# 如果有用户名密码
set http_proxy_user=user
set http_proxy_pass=pass

set https_proxy_user=user
set https_proxy_pass=pass

# 不走代理的IP
# set NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24


# Ubuntu 下命令为 export
# export http_proxy=http://127.0.0.1:1080
  • 恢复默认
1
2
3
4
# 恢复
set http_proxy=

set https_proxy=