badvpn-tun2socks.8 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. .TH badvpn-tun2socks 8 "February 2012"
  2. .SH NAME
  3. badvpn-tun2socks \- create a TUN device to route TCP traffic through a SOCKS server
  4. .SH SYNOPSIS
  5. .PP
  6. .B
  7. badvpn-tun2socks
  8. .br
  9. [\fB\-\-help\fR]
  10. .br
  11. [\fB\-\-version\fR]
  12. .br
  13. [\fB\-\-logger\fR <stdout/syslog>]
  14. .br
  15. [\fB\-\-syslog-facility\fR <string>] [\fB\-\-syslog-ident\fR <string>]
  16. .br
  17. [\fB\-\-loglevel\fR <0-5/none/error/warning/notice/info/debug>]
  18. .br
  19. [\fB\-\-channel-loglevel\fR <channel-name> <0-5/none/error/warning/notice/info/debug>] ...
  20. .br
  21. [\fB\-\-tundev\fR <name>]
  22. .br
  23. \fB\-\-netif\-ipaddr\fR <ipaddr>
  24. .br
  25. \fB\-\-netif\-netmask\fR <ipnetmask>
  26. .br
  27. \fB\-\-socks\-server\-addr\fR <addr>
  28. .br
  29. [\fB\-\-udpgw-remote-server-addr\fR <addr>]
  30. .br
  31. [\fB\-\-udpgw-max-connections\fR <number>]
  32. .br
  33. [\fB\-\-udpgw-connection-buffer-size\fR <number>]
  34. .PP
  35. Address format is a.b.c.d:port (IPv4) or [addr]:port (IPv6).
  36. .SH DESCRIPTION
  37. .PP
  38. badvpn-tun2socks
  39. is a network utility used to "socksify" TCP connections at the network
  40. layer. It implements a TUN device which accepts all incoming TCP
  41. connections (regardless of destination IP), and forwards them through
  42. a SOCKS server. This allows you to forward all connections through
  43. SOCKS, without any need for application support. It can be used, for
  44. example, to forward connections through a remote SSH server.
  45. .SH EXAMPLE
  46. .PP
  47. This example demonstrates using tun2socks in combination with SSH's dynamic forwarding feature.
  48. Connect to the SSH server, passing -D localhost:1080 to the ssh
  49. command to enable dynamic forwarding. This will make ssh open a local
  50. SOCKS server which tun2socks forward connection through.
  51. First create a TUN device (eg. using openvpn):
  52. .nf
  53. openvpn --mktun --dev tun0 --user <someuser>
  54. .fi
  55. Configure the IP of the new tun device:
  56. .nf
  57. ifconfig tun0 10.0.0.1 netmask 255.255.255.0
  58. .fi
  59. Now start the badvpn-tun2socks program:
  60. .nf
  61. badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 \\
  62. --socks-server-addr 127.0.0.1:1080
  63. .fi
  64. Note that the address 10.0.0.2 is not a typo. It specifies the IP address of the virtual
  65. router inside the TUN device, and must be different from the IP of the
  66. TUN interface itself (but in the same subnet).
  67. Now you should be able to ping the virtual router's IP (10.0.0.2):
  68. .nf
  69. ping -n 10.0.0.2
  70. .fi
  71. All that remains is to route connections through the TUN device
  72. instead of the existing default gateway. This is done as follows:
  73. 1. Add a route to the SSH server through your existing gateway, with a
  74. lower metric than the original default route.
  75. 2. If your DNS servers are in a network that is not direcly attached (e.g. in the Internet),
  76. also add routes for them (like for the SSH server). This is
  77. needed because tun2socks does not forward UDP by default (see below).
  78. 3. Add a default route through the virtual router in the TUN device,
  79. with a lower metric than the original default route, but higher than
  80. the SSH and DNS routes.
  81. This will make all external connections go through the TUN device,
  82. except for the SSH connection (else SSH would go through the TUN
  83. device, which would go through... SSH).
  84. For example (assuming there are no existing default routes with metric
  85. <=6; otherwise remove them or change their metrics):
  86. .nf
  87. route add <IP_of_SSH_server> gw <IP_of_original_gateway> metric 5
  88. <same for DNS>
  89. route add default gw 10.0.0.2 metric 6
  90. .fi
  91. .SH UDP FORWARDING
  92. tun2socks can forward UDP, however this requires a forwarder daemon, badvpn-udpgw to run
  93. on the remote SSH server:
  94. .nf
  95. badvpn-udpgw --listen-addr 127.0.0.1:7300
  96. .fi
  97. Then tell tun2socks to forward UDP via the forwarder:
  98. .nf
  99. --udpgw-remote-server-addr 127.0.0.1:7300
  100. .fi
  101. .SH COPYRIGHT
  102. .PP
  103. Copyright \(co 2010 Ambroz Bizjak <ambrop7@gmail.com>
  104. .br
  105. This is free software; see the source for copying conditions. There is NO
  106. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.