TORSOCKS(8)
π TORSOCKS(8) β NAME π
okay bestie, meet torsocks β the library for intercepting outgoing network connections and redirecting them through the Tor SOCKS proxy. literally iconic β¨
πΈ DESCRIPTION πΈ
Torsocks overloads the libc symbols used for Internet communication, such as the connect(2) system call. Using that technique, the library sends everything through the Tor network β including DNS resolution done by the application. no cap π
For DNS, the gethostbyname(3) family functions are rerouted through Tor. Please note that the ISC res_* API is currently not supported. π«Ά
Hereβs an example of how to use the torsocks library with ssh(1):
$ LD_PRELOAD=/path/to/libtorsocks.so ssh -l kalexander -p 1234
prism.nsa.gov [...]
β¨ SHELL USAGE β¨
Set LD_PRELOAD to load the library, then use applications as normal. The syntax to force preload of the library for different shells is specified below:
Bash, Ksh and Bourne shell:
$ export LD_PRELOAD=/path/to/libtorsocks.so
C Shell:
$ setenv LD_PRELOAD=/path/to/libtorsocks.so
This process can be automated (for Bash, Bourne and Korn shell users) for a single command or for all commands in a shell session by using the torsocks(1) script. so convenient π
You can also setup torsocks(1) in such a way that all processes automatically use it β a very useful configuration. Please refer to the torsocks script documentation for more information. π
π ENVIRONMENT VARIABLES π
TORSOCKS_CONF_FILEβ this environment variable overrides the default location of the torsocks configuration file. This variable is not honored if the program torsocks is embedded in is setuid. πTORSOCKS_LOG_LEVELβ enables the logging level of the torsocks library. By default, warnings and errors are printed (level3). Note that each level includes the lower ones except the1which disables any possible logging. (default:3)1β No log at all.2β Error messages.3β Warning messages.4β Notice messages.5β Debug messages.
TORSOCKS_LOG_TIMEβ controls whether or not the time is added to each logging line. (default:1)TORSOCKS_LOG_FILE_PATHβ if set, torsocks will log in the file set by this variable. (default:stderr)TORSOCKS_USERNAMEβ sets the username for the SOCKS5 authentication method. Password MUST be set also with the variable below. πTORSOCKS_PASSWORDβ sets the password for the SOCKS5 authentication method. Username MUST be set also with the variable above. πTORSOCKS_TOR_ADDRESSβ sets the Tor IP address. Hostnames are not supported here. (default:127.0.0.1)TORSOCKS_TOR_PORTβ sets the Tor port. (default:9050)TORSOCKS_ALLOW_INBOUNDβ allows inbound connections so the application can accept and listen for connections.TORSOCKS_ISOLATE_PIDβ sets the username and password for the SOCKS5 authentication method to a PID/current time based value automatically. Username and Password MUST NOT be set. π¨
π«Ά KNOWN ISSUES π«Ά
π¦ DNS π¦
Torsocks is not able to send DNS queries through Tor since UDP is not supported. Thus, any UDP socket is denied. However, DNS queries that it can intercept are sent to Tor and sent back to the caller. the more you know πΈ
π ERRORS π
Torsocks might generate error messages and print them to stderr when there are problems with the configuration file or the SOCKS negotiation with the Tor daemon. The TORSOCKS_LOG_LEVEL environment variable controls that behavior as well as the log file option. Keep in mind that this library can output on the stderr of the application. π
π LIMITATIONS π
Outgoing TCP connections can only be proxified through the Tor network.
Torsocks forces the libc resolver to use TCP for name queries. If it does this, it does it regardless of whether or not the DNS to be queried is local or not. This introduces overhead and should only be used when needed. fair warning β¨
Torsocks uses ELF dynamic loader features to intercept dynamic function calls from programs in which it is embedded. As a result, non-ELF executables, or executables that make system calls directly with the system call trap (int 0x80) are not supported. π
π FILES π
/etc/tor/torsocks.conf β default torsocks configuration file.
π SEE ALSO π
π AUTHOR π
David Goulet <dgoulet@ev0ke.net>
thatβs the whole vibe π β signing off from TORSOCKS(8), dated August 24th, 2013. stay safe out there, bestie π¦β¨
π¦ where this page comes from
- alpine 3.24: torsocks-doc 2.5.0-r0 Β· GPL-2.0
- arch rolling: torsocks 2.5.0-1 Β· GPL-2.0-or-later
- nixos 26.05: torsocks 2.5.0
- nixpkgs unstable: torsocks 2.5.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms