Skip to content

Instantly share code, notes, and snippets.

@waynelwz
Forked from libChan/wsl_clash_proxy.sh
Created October 9, 2022 09:09
Show Gist options
  • Select an option

  • Save waynelwz/752712dee0d9d4219e3e4bebfe4b4c3b to your computer and use it in GitHub Desktop.

Select an option

Save waynelwz/752712dee0d9d4219e3e4bebfe4b4c3b to your computer and use it in GitHub Desktop.

Revisions

  1. @libChan libChan revised this gist Dec 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wsl_clash_proxy.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # 需要开启wsl.conf的自动生成,再运行以下命令
    # https://zhuanlan.zhihu.com/p/153124468

    #!/bin/sh
    # 添加到环境变量设置中,例如~/.zshrc
    export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
    export https_proxy="http://${hostip}:7890"
    export http_proxy="http://${hostip}:7890"
  2. @libChan libChan revised this gist Nov 26, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions wsl_clash_proxy.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    # WSL中的DNS server在/etc/resolv.conf中查看,该文件是由/etc/wsl.conf自动生成的。
    # 如果关闭了wsl.conf中自动生成resolve.conf并自行修改了resolve.conf,DNS nameserver并不是本机win ip
    # 需要开启wsl.conf的自动生成,再运行以下命令
    # https://zhuanlan.zhihu.com/p/153124468

    #!/bin/sh
    export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
  3. @libChan libChan renamed this gist Nov 26, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @libChan libChan renamed this gist Nov 26, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @libChan libChan created this gist Nov 26, 2021.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # WSL通过Win访问网络,所以WSL的网关指向的是Windows,DNS服务器指向的也是Windows,设置WSL的proxy为win的代理ip+端口即可
    # WSL中的DNS server在/etc/resolv.conf中查看,该文件是由/etc/wsl.conf自动生成的。
    # 如果关闭了wsl.conf中自动生成resolve.conf并自行修改了resolve.conf,DNS nameserver并不是本机win ip
    # 需要开启wsl.conf的自动生成,再运行以下命令

    #!/bin/sh
    export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
    export https_proxy="http://${hostip}:7890"
    export http_proxy="http://${hostip}:7890"