如何强制所有的数据包通过SSH隧道?

我们有一个SSH隧道( ssh -ND 127.0.0.1:8080 [email protected] ),如果将它们指向127.0.0.1:8080作为socks5代理,那么对于浏览器来说工作正常,但其他通信仍然不通过这个通道。

我怎么会绝对所有的stream量通过SSH隧道?

任何工具,我需要的设置?

我使用的系统是Debian和MacOS,所以如果解决scheme对于这两个平台来说或多或less是一般的,那么这个系统会更好。

您可以使用ssh创buildVPN。 这里是man ssh的相关部分:

 SSH-BASED VIRTUAL PRIVATE NETWORKS ssh contains support for Virtual Private Network (VPN) tunnelling using the tun(4) network pseudo-device, allowing two networks to be joined securely. The sshd_config(5) configuration option PermitTunnel controls whether the server supports this, and at what level (layer 2 or 3 traffic). The following example would connect client network 10.0.50.0/24 with remote network 10.0.99.0/24 using a point-to-point connection from 10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway to the remote network, at 192.168.1.15, allows it. On the client: # ssh -f -w 0:1 192.168.1.15 true # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252 # route add 10.0.99.0/24 10.1.1.2 On the server: # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252 # route add 10.0.50.0/24 10.1.1.1 

最后,您将拥有可用于转发stream量的隧道接口。