LinuxCommandLibrary

torify

Route network traffic through Tor

TLDR

Route traffic via Tor

$ torify [command]
copy

Toggle Tor in shell
$ torify [on|off]
copy

Spawn a Tor-enabled shell
$ torify --shell
copy

Check for a Tor-enabled shell
$ torify show
copy

Specify Tor configuration file
$ torify -c [config-file] [command]
copy

Use a specific Tor SOCKS proxy
$ torify -P [proxy] [command]
copy

Redirect output to a file
$ torify [command] > [path/to/output]
copy

SYNOPSIS

torify [arguments...]

PARAMETERS

command
    The command to run through Tor.

[arguments...]
    Any arguments to pass to the specified command.

DESCRIPTION

torify is a shell script that wraps other commands to redirect their TCP and UDP traffic through the Tor network. It achieves this by setting environment variables, primarily LD_PRELOAD, to load a shared library (typically libtorify.so) that intercepts network calls and routes them via Tor's SOCKS proxy, usually running on localhost port 9050 (or 9150 for the Tor Browser Bundle). This effectively anonymizes the application's network communication, hiding the user's real IP address. Torify can be used with almost any network-aware application. However, it is essential to understand its limitations. It does not anonymize DNS requests by default unless configured appropriately. Also, applications that bypass standard networking libraries might not be torified successfully. The script attempts to handle different operating systems and configurations, though manual configuration may be needed in some cases. It requires that the Tor service be running and accessible for redirection to succeed.

CAVEATS

torify does NOT guarantee perfect anonymity.
DNS requests are often not proxied by default. Applications that directly use IP addresses (instead of hostnames) or bypass standard system libraries may leak your actual IP address. Always verify that traffic is routed through Tor using a tool like tcpdump before relying on torify for sensitive operations.

CONFIGURATION

The /etc/tor/torrc file (or equivalent system location) configures the Tor daemon. torify relies on Tor being properly configured and running for successful operation.

TROUBLESHOOTING

If torify doesn't work as expected, check the Tor logs for errors. Ensure Tor is running, and that the SOCKS proxy is accessible. Verify that libtorify.so is correctly loaded using ldd. Common problems include incorrect SOCKS port configuration, DNS leaks, and applications bypassing Tor.

DNS LEAKS

To prevent DNS leaks, you can configure torrc with options like DNSPort and AutomapHostsOnResolve. Tools like torsocks provide built-in DNS leak protection, but torify requires proper configuration.

HISTORY

The torify script has been developed and maintained within the Tor project to provide a simple way to route applications through the Tor network. Its usage has grown with the increasing need for online privacy and anonymity. It has evolved over time to support various platforms and handle different networking scenarios.

SEE ALSO

torsocks(1), tor(1)

Copied to clipboard