torify: Practical Guide to Route Traffic Through Tor


torify: Practical Guide to Route Traffic Through Tor

Torifying commands lets you route their network traffic through the Tor network. Note: torify is deprecated and now acts as a backwards-compatible wrapper of torsocks. Use torsocks directly for newer setups, but torify remains available for legacy workflows.

Quick-start examples

  • Route a single command through Tor
torify curl -s https://check.torproject.org/api/ip
  • Toggle Tor in the current shell on or off
torify on
# run some commands with Tor routing...
torify off
  • Spawn a Tor-enabled shell
torify --shell
  • Check if you’re in a Tor-enabled shell
torify show
  • Use a specific Tor configuration file
torify -c /path/to/torrc curl -s https://check.torproject.org/api/ip
  • Use a specific Tor SOCKS proxy
torify -P 127.0.0.1:9050 curl -s https://check.torproject.org/api/ip
  • Redirect command output to a file
torify curl -s http://example.com > output.html

How torify works (at a glance)

  • It’s a wrapper around torsocks that routes the target command’s traffic through the Tor network.
  • It does not make you anonymous by itself; it only redirects the command’s traffic. Your local machine and other processes may still reveal 情報.

Common pitfalls

  • Tor not running: If Tor isn’t active, torify will fail to connect. Ensure the Tor service or a SOCKS proxy is up.
  • DNS leaks: When routing traffic through Tor, DNS requests can still leak if not configured properly. Prefer using Tor-enabled clients or proper DNS handling.
  • Performance impact: Expect slower requests due to Tor routing; don’t use torify for high-speed tasks.
  • Misunderstanding torify vs. torsocks: torify is a compatibility wrapper. For new setups, consider using torsocks directly or other modern Tor clients.
  • Privilege considerations: Some environments require elevated privileges to access the SOCKS proxy or to bind to specific network interfaces.

When to use torify

  • Quick, legacy-compatible way to route a single command through Tor.
  • Scripts that were written around torify and torsocks and have not been modernized.

Alternatives and next steps

  • Learn torsocks directly for more control and modern features.
  • If you just need to route a browser or a specific app, check if there are Tor-friendly versions or proxies that suit your use case.
  • Verify anonymity and privacy by testing with check.torproject.org or similar services.

Troubleshooting checklist

  1. Is Tor running or is a SOCKS proxy accessible on the expected port? (default: 9050)
  2. Does the target command work without torify? If not, the issue is not Tor-related.
  3. Are environment variables interfering with proxy config (http_proxy, https_proxy)?
  4. Check permissions and SELinux/AppArmor that might block proxy usage.
  5. Review torify’s deprecation status and consider migrating to torsocks or direct Tor tooling.

Summary

torify offers a simple, quick path to run commands through the Tor network, acting as a compatibility wrapper around torsocks. Use it for quick experiments or legacy scripts, but be mindful of its deprecated status and the privacy nuances of routing traffic through Tor.

See Also