Skip to content

[Feature] A suggestion about tun2socks automatically configuring IP #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tyfxgzs opened this issue Feb 18, 2025 · 1 comment
Open
Assignees

Comments

@tyfxgzs
Copy link

tyfxgzs commented Feb 18, 2025

Description

I have a general understanding of how to use the project. Now I want to ask if I can automatically configure the IP of tun through the configuration file instead of creating the IP first and then starting tun2socks.

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

@xjasonlyu xjasonlyu changed the title [Feature] A suggestion about tun2socks automatically configuring IP. [Feature] A suggestion about tun2socks automatically configuring IP Apr 15, 2025
@xjasonlyu xjasonlyu self-assigned this Apr 15, 2025
@xjasonlyu
Copy link
Owner

Actually, if you want some auto configuration through config files, you can do something like:

For example, in macOS, create a setup_macos.sh script to set up the route, e.g.:

#!/bin/sh

sudo ifconfig utun123 198.18.0.1 198.18.0.1 up
sudo route add -net 1.0.0.0/8 198.18.0.1
sudo route add -net 2.0.0.0/7 198.18.0.1
sudo route add -net 4.0.0.0/6 198.18.0.1
sudo route add -net 8.0.0.0/5 198.18.0.1
sudo route add -net 16.0.0.0/4 198.18.0.1
sudo route add -net 32.0.0.0/3 198.18.0.1
sudo route add -net 64.0.0.0/2 198.18.0.1
sudo route add -net 128.0.0.0/1 198.18.0.1
sudo route add -net 198.18.0.0/15 198.18.0.1

And then, run:

$ sudo tun2socks-darwin-amd64 -device utun123 -interface en0 --tun-post-up "sh -c './setup_macos.sh'" --proxy socks5://xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants