DEV Community

Li
Li

Posted on

Use proxychains in WSL

A WSL distro changes its IP and gateway address every time it restarts, so using proxychains would be a painful experience because the proxychains config file can not use domain names. The proxy runs on the host, forwarding traffic to a remote server.

So a script to dynamically generate proxychains config file would be helpful.

#!/bin/bash
# wsl's host ip address may change every time it reboots,
# this is a problem if you map your host address as proxy.
# Use the script to generate a new config of proxychains
# each time proxychains runs.
# put an entry
# http wsl-host 3128
# in your /etc/proxychains.conf
# Copy the script as ./local/bin/wsl-proxychains.sh
# run your program with proxychains like
# wsl-proxychains.sh <YOUR PROGRAM>
gateway=`ip route|grep default|grep eth0|cut -d' ' -f 3`
sed "s/wsl-host/${gateway}/g" /etc/proxychains4.conf > /tmp/proxychains.conf
proxychains -f /tmp/proxychains.conf $@

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay