Skip to content
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

Does gotun2socks work on macOS? #1

Open
liudanking opened this issue Aug 29, 2016 · 8 comments
Open

Does gotun2socks work on macOS? #1

liudanking opened this issue Aug 29, 2016 · 8 comments

Comments

@liudanking
Copy link

There is a tun_linux.go file in bin directory, but missing tun_darwin.go.

@yinghuocho
Copy link
Owner

I think the package itself works on macOS, as the code does not rely on OS-specific structs/interfaces. Thought I did't test.

The executable in bin directory only works on Linux. But it should be not hard to make it works on macOS. The only thing missing is a procedure that opens a tun device and returns a os.File object.

@liudanking
Copy link
Author

I will have a try, and give my feedback ASAP.

@yinghuocho
Copy link
Owner

@liudanking gotun2socks works on macOS now. You can have a try. The problem only sets up the utun interface, you need to take care of routing yourself.

@FlowerWrong
Copy link

FlowerWrong commented Dec 7, 2016

Could you give me a route command example for OSX? I am not familiar with OSX route command. I have try some commands below.

As you see.

Generaly the process includes changing default route to the tun/tap device, and exclude IP addresses of remote servers to go through the original network device so that traffic forwarded from local SOCKS5 proxy to remote servers would not loop back.

Follow command work for me. But I do not know it is corrent or not?

# start shadowsocks server on vps with udp relay
# start shadowsocks client on your computer with udp relay

sudo ./gotun2socks --local-socks-addr 127.0.0.1:1080

sudo route add -net 0.0.0.0 10.0.0.1 -netmask 128.0.0.0
sudo route add -net 128.0.0.0 10.0.0.1 -netmask 128.0.0.0

orig_gw=$(netstat -nr | grep --color=never '^default' | grep -v 'utun' | sed 's/default *\([0-9\.]*\) .*/\1/' | head -1)
sudo route add my_ss_server $origin_gw

@yinghuocho
Copy link
Owner

@FlowerWrong I think the commands you posted should be sufficient. The 2th and 3th commands change default route to the new utun device. The 4th command extracts previous default gateway. The 5th command specifies your ss_server to go through the previous gateway.

@athrunsun
Copy link

@yinghuocho @FlowerWrong

I'm sorry if this is a dumb question - but is sudo ip tuntap add dev tun0 mode tun user foobar posted here only necessary on linux? Because there's no ip command available on osx in the first place.

Or, will sudo gotun2socks --local-socks-addr 127.0.0.1:1080 create tun device automatically on both linux and osx?

@FlowerWrong
Copy link

see this comment

@athrunsun
Copy link

@FlowerWrong Is -netmask 128.0.0.0 a must? What difference will it make when I set it to 255.255.255.0?

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

4 participants