<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Network Settings on Qingchen Yu</title><link>https://zhgyqc.site/tags/network-settings/</link><description>Recent content in Network Settings on Qingchen Yu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 01 Nov 2026 21:35:04 +0800</lastBuildDate><atom:link href="https://zhgyqc.site/tags/network-settings/index.xml" rel="self" type="application/rss+xml"/><item><title>WSL2网络代理配置（实现自由切换）</title><link>https://zhgyqc.site/blogs/2023-12-12-wsl-proxy-config/</link><pubDate>Tue, 12 Dec 2023 00:00:00 +0000</pubDate><guid>https://zhgyqc.site/blogs/2023-12-12-wsl-proxy-config/</guid><description>在使用代理的环境中，灵活切换是否使用代理是一个常见的需求。
本文介绍了如何通过修改 .bashrc 文件实现这一目标。配置过程中主要参考了WSL2 的开发环境配置 和在 WSL2 中使用 Clash for Windows 代理连接 。
首先需要在Windows中的软件配置代理设置。
然后在WSL下通过vim ~/.bashrc命令进入 .bashrc 文件将启用和禁用代理的过程封装为两个短命令的代码放入其中并保存。
# 网络代理设置 setp() { host_ip=$(cat /etc/resolv.conf | grep &amp;#34;nameserver&amp;#34; | cut -f 2 -d &amp;#34; &amp;#34;) export http_proxy=&amp;#34;http://$host_ip:7890&amp;#34; export https_proxy=&amp;#34;http://$host_ip:7890&amp;#34; echo &amp;#34;Proxy enabled.&amp;#34; } usetp() { unset http_proxy unset https_proxy echo &amp;#34;Proxy disabled.&amp;#34; } 再修改保存后，执行source .bashrc使其生效后即可使用，具体使用方式见下图</description></item></channel></rss>