I am not very experienced with socks proxy. Recently I found the tun2socks. If you open the link, in the 1st paragraph it says :

It implements a TUN virtual network interface which accepts all incoming TCP connections (regardless of destination IP), and forwards them through a SOCKS server.

after that it says :

It can be used, for example, to forward connections through a remote SSH server or through Tor.

I have two questions:

Q1. I can't link the two sayings, I understand the 1st part that it forwards all TCP connections through a SOCKS server, but why it says it can be used to forward connections through SSH server? It sounds like SSH server is the SOCKS server. Could someone please clarify this to me?

Also, if someone could also give a general introduction about tun2socks, It would be great to me. Thanks in advance.

Q2. Since tun2socks is part of a thing called BadVPN, I am wondering how does socks proxy collaborate with VPN? Any examples for me to understand?

  • 1
    Hi, author of tun2socks here. A1) Yes, it can forward through ssh because SSH implements dynamic port forwarding, available through a local SOCKS server (this is the -D option). So this ability is just a consequence of using SOCKS. A2) Tun2socks is functionally its own thing. You can compile just the tun2socks program and not the VPN stuff by specifying appropriate options to cmake. Note, tun2socks makes use of lwIP the open-source IP stack where the magic of translating between packets and transport-layer data happens. I have only made a few hacks in lwIP to make it possible to integrate. – Ambroz Bizjak Oct 14 '15 at 16:35

You can use the ssh command line to run a SOCKS server that will connect to the host you specify:

ssh -D 2001 user@host.com

This will start a SOCKS server on port 2001 that will route requests to host.com. They call this feature "dynamic application-level port forwarding".

Some more:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.