Wsl2中访问win10的localhost网络代理

转:https://devdojo.com/mvnarendrareddy/access-windows-localhost-from-wsl2

grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'

执行上面代码,得到一个ip,这个ip代替127.0.0.1或locahost即可。

参考链接:wsl2配置使用windows网络代理

参考链接2:设置代理脚本命令

总结:

export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')

SOCKS5_PORT=10808
alias proxy='
    export https_proxy="socks5://${hostip}:${SOCKS5_PORT}";
    export http_proxy="socks5://${hostip}:${SOCKS5_PORT}";
    echo -e "Acquire::http::Proxy \"http://${hostip}:${SOCKS5_PORT}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
    echo -e "Acquire::https::Proxy \"http://${hostip}:${SOCKS5_PORT}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
'
alias unproxy='
    unset https_proxy;
    unset http_proxy;
    unset all_proxy;
    sudo sed -i -e '/Acquire::http::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
    sudo sed -i -e '/Acquire::https::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
'

需要删除原文中:

export all_proxy="socks5://${hostip}:1080"

这行,不然代理软件的日志中会出现:

unknown Socks version: 67

No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next