xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.86k stars 407 forks source link

Quick start guide / examples? #32

Closed TheLinuxGuy closed 3 years ago

TheLinuxGuy commented 3 years ago

Could you consider adding more information to your project and example quick start guides?

I'm struggling to setup and verify this is working - I am not using your docker image, I compiled the binary and try to run on it on the machine and the tun0 interface on linux debian 10 is not being created.

If there was a quickstart guide with some minimum requirements (or possibly binary downloads) I could quickly run some tests - right now I am trying to tunnel all ICMP/UDP/TCP traffic thru a shadowsocksr server (VPS) and my local machine/client (debian 10) is where I am trying to do iperf3 tests via the tun0 interface of tun2socks.

Trying to compare tun2socks performance with udp2raw and others. Right now I couldn't find some examples in english or more information and when I run the binary all I see is this

root@gw:~# ./tun2socks-linux-amd64  -device tun://tun0 -proxy socks5://127.0.0.1:1080
INFO[0000] [STACK] tun://tun0 <-> socks5://127.0.0.1:1080

There is no tun0 interface created and shown via 'ifconfig' nor an error... so I am unsure if this is even working. I did try to run this script but nothing happens. https://github.com/xjasonlyu/tun2socks/wiki/Load-tun-module - I am unclear if there are more steps needed to make this work. The first page of the wiki says running command 'tun2socks-linux-amd64 -device tun://tun0 -proxy socks5://127.0.0.1:1080' should be enough to bring up the tunnel.

thanks

xjasonlyu commented 3 years ago

Intros would be completed soon.

There are some tips for you though:

  1. tun0 was created but not shown because it was not up yet, you can see it by using ifconfig -a
  2. ICMP cannot be "proxied" by any proxies, it would be simply replied by tun2socks
  3. shadowsocksr was already deprecated years ago, try trojan or v2ray etc.
  4. tun2socks + udp2raw, that's new, I don't know if they could use together🤨
  5. be aware of traffic loop if you have proxy server and tun2socks in the same host
xjasonlyu commented 3 years ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0
TheLinuxGuy commented 3 years ago

thanks for the pointers.

did this before bringing up tun0 as suggested - added a few minor things. my LTE cellular ISP has mtu issues so lowered mtu.

# ip tuntap add mode tun dev tun0
# ip link set dev tun0 up
# ip link tun0 mtu 1300
root@gw:~# ip addr add 192.168.66.1 dev tun0

I see some traffic going thru it now thanks

# ./tun2socks-linux-amd64  -device tun://tun0 -proxy socks5://127.0.0.1:1080
INFO[0000] [STACK] tun://tun0 <-> socks5://127.0.0.1:1080
INFO[0043] [UDP] 192.168.66.1:45363 --> 64.142.54.12:123
INFO[0043] [UDP] 192.168.66.1:45363 <-- 64.142.54.12:123
INFO[0323] [UDP] 192.168.66.1:37388 --> 8.8.8.8:53
INFO[0323] [UDP] 192.168.66.1:52008 --> 8.8.8.8:53
INFO[0323] [UDP] 192.168.66.1:52008 <-- 8.8.8.8:53
INFO[0323] [UDP] 192.168.66.1:54620 --> 8.8.8.8:53
INFO[0323] [UDP] 192.168.66.1:37388 <-- 8.8.8.8:53
INFO[0327] [UDP] 192.168.66.1:51552 --> 8.8.8.8:53
INFO[0328] [UDP] 192.168.66.1:51552 <-- 8.8.8.8:53
INFO[0328] [UDP] 192.168.66.1:55699 --> 1.1.1.1:53
INFO[0328] [UDP] 192.168.66.1:55699 <-- 1.1.1.1:53
INFO[0351] [UDP] 192.168.66.1:60114 --> 8.8.8.8:53
INFO[0351] [UDP] 192.168.66.1:60114 <-- 8.8.8.8:53
INFO[0351] [UDP] 192.168.66.1:53119 --> 8.8.8.8:53
INFO[0351] [UDP] 192.168.66.1:53119 <-- 8.8.8.8:53
INFO[0351] [UDP] 192.168.66.1:39862 --> 8.8.8.8:53
INFO[0351] [UDP] 192.168.66.1:39862 <-- 8.8.8.8:53
INFO[0352] [UDP] 192.168.66.1:55163 --> 8.8.8.8:53
INFO[0352] [UDP] 192.168.66.1:55163 <-- 8.8.8.8:53
INFO[0352] [UDP] 192.168.66.1:59457 --> 8.8.8.8:53
INFO[0352] [UDP] 192.168.66.1:59457 <-- 8.8.8.8:53
INFO[0354] [UDP] 192.168.66.1:42417 --> 8.8.8.8:53
INFO[0354] [UDP] 192.168.66.1:42417 <-- 8.8.8.8:53
INFO[0360] [UDP] 192.168.66.1:43068 --> 8.8.8.8:53
INFO[0360] [UDP] 192.168.66.1:43068 <-- 8.8.8.8:53
INFO[0360] [UDP] 192.168.66.1:37039 --> 8.8.8.8:53
INFO[0360] [UDP] 192.168.66.1:37039 <-- 8.8.8.8:53
INFO[0386] [TCP] 192.168.66.1:37624 <-> 151.101.6.219:80
INFO[0403] [TCP] 192.168.66.1:37630 <-> 151.101.6.219:80
xjasonlyu commented 3 years ago

If you can see traffic logs and connection is ok then yes, it works.

BTW, the MTU of tun0 is not related with your interface of ISP, it could be set to 9000 if you want. you can set MTU with -mtu 9000 in tun2socks.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

sonvirgo commented 11 months ago

Using 127.0.0.1 socks, require policy based routing As of now only Linux works See my solution below tun2socks -> localhost cause loop hole, which stop 127.0.0.1 socks server to functioning. Depend on the socks server implementation, but usually socks port not open if a stream is not established See my solution for example Psiphon 127.0.0.1 socks Only work on Linux, support iptables user id range policy, or cgroup. tun2socks-127.0.0.1-loopback

Hhk78 commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

sonvirgo commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

See my explained solution https://github.com/sonvirgo/tun2socks-127.0.0.1-loopback Your use case is same as mine I use Psiphon which is MEEK Where the nodes' IP are unknown before hand

Hhk78 commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

See my explained solution https://github.com/sonvirgo/tun2socks-127.0.0.1-loopback Your use case is same as mine I use Psiphon which is MEEK Where the nodes' IP are unknown before hand

What are Psiphon and MEEK? And I didn't understand anything from the link you sent. I'm using translation, sorry for English

sonvirgo commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

See my explained solution https://github.com/sonvirgo/tun2socks-127.0.0.1-loopback Your use case is same as mine I use Psiphon which is MEEK Where the nodes' IP are unknown before hand

What are Psiphon and MEEK? And I didn't understand anything from the link you sent. I'm using translation, sorry for English

Hey duđe Do you know anything about networking? Or just mimic So how do you say some thing about Tor while you don't know any thing about Meek? You ara the same as almost the rest here! Google is free for you

Hhk78 commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

See my explained solution https://github.com/sonvirgo/tun2socks-127.0.0.1-loopback Your use case is same as mine I use Psiphon which is MEEK Where the nodes' IP are unknown before hand

What are Psiphon and MEEK? And I didn't understand anything from the link you sent. I'm using translation, sorry for English

Hey duđe Do you know anything about networking? Or just mimic So how do you say some thing about Tor while you don't know any thing about Meek? You ara the same as almost the rest here! Google is free for you

There was no need to be offensive. I didn't know that this thing called Meek had anything to do with Tor. Thanks for providing this information. I'm sorry about your English. I use translation.

sonvirgo commented 7 months ago

For now, before you start tun2socks

ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0  # optional
ip link set dev tun0 up

# config your route table, for example:
ip route replace default dev tun0

When I do this, my entire internet connection is cut off and therefore tun2socks cannot connect to the proxy server. And I will use the tun2socks program to integrate the Tor network into the entire system, but Tor cannot communicate with Tor nodes because it cannot access the internet. Is there a solution to this?

See my explained solution https://github.com/sonvirgo/tun2socks-127.0.0.1-loopback Your use case is same as mine I use Psiphon which is MEEK Where the nodes' IP are unknown before hand

What are Psiphon and MEEK? And I didn't understand anything from the link you sent. I'm using translation, sorry for English

Hey duđe Do you know anything about networking? Or just mimic So how do you say some thing about Tor while you don't know any thing about Meek? You ara the same as almost the rest here! Google is free for you

There was no need to be offensive. I didn't know that this thing called Meek had anything to do with Tor. Thanks for providing this information. I'm sorry about your English. I use translation.

Sorry for your excellent English plus dumb superficial knowledge I made up my mind to try to understand what you want to know technically "I didn't know that this thing called Meek had anything to do with Tor?"