SOCKS5 Proxy Guide: Routing Traffic Through Tor with proxychains4

This is a quick guide to routing command-line traffic through a SOCKS5 proxy using Tor Browser’s built-in Tor instance and proxychains4.

Why use a SOCKS5 proxy #

Routing traffic through a SOCKS5 proxy lets you make requests that exit from a different IP than your own, useful for testing.

Prerequisites #

  • Tor Browser installed and running (its bundled Tor instance listens on 127.0.0.1:9150 by default, this is different from the system tor package, which uses port 9050)
  • proxychains4 installed

1. Install proxychains4 #

sudo apt install proxychains4

2. Point it at Tor Browser’s SOCKS5 port #

Confirm Tor Browser’s proxy is actually listening:

ss -tulpn | grep 9150

You should see something like:

tcp   LISTEN 0      4096   127.0.0.1:9150   0.0.0.0:*   users:(("tor",pid=...,fd=...))

Edit the config:

sudo vim /etc/proxychains4.conf

Comment out the default line at the bottom:

#socks4 127.0.0.1 9050

And add:

socks5 127.0.0.1 9150

Make sure proxy_dns is uncommented near the top of the file. This routes hostname resolution through the proxy too, instead of leaking DNS queries locally.

3. Verify your exit IP #

curl ipconfig.fi              # your real IP
proxychains4 curl ipconfig.fi # Tor-routed IP

Simple as that!