Raspberry Pi 3 OpenWRT & Redsocks SOCKS5 Proxy Setup Guide

LoyBuff

Activist
BFD MEMBER
PREMIUM
MEMBER
Joined
Jan 18, 2025
Messages
112
Reaction score
3,398
Deposit
0$
1748882586763.png


Hello everyone, today I will guide you step by step through the process of turning a Raspberry Pi 3 into a router with OpenWRT, installing a SOCKS5 proxy with Redsocks, and sharing the internet via WiFi. This will make any device connected to the Raspberry Pi browse through the proxy and appear at its location. I will explain each step in a simple and clear way.


  1. Required Materials
  • Raspberry Pi 3
  • MicroSD Card (at least 8 GB)
  • Ethernet Cable
  • Raspberry Pi Power Supply
  • Computer with a microSD card reader
  • Internet Connection
  1. Installing OpenWRT on the Raspberry Pi
Step 1: Download OpenWRT

  1. Go to the official OpenWRT website: https://openwrt.org/
  2. Find the version compatible with Raspberry Pi 3 and download the image (.img.gz).
Step 2: Flash OpenWRT to the MicroSD Card

  1. Use a tool like Rufus or Balena Etcher.
  2. Insert the microSD card into your computer.
  3. Select the OpenWRT image and the microSD card.
  4. Click on "Flash" or "Write" and wait for it to finish.
Step 3: Insert the MicroSD Card and Boot the Raspberry Pi

  1. Insert the microSD card into the Raspberry Pi.
  2. Connect it to the router with the Ethernet cable.
  3. Turn it on and wait for it to boot.
  4. Configuring OpenWRT
Step 1: Access the OpenWRT Web Interface

  1. On your computer, connect to the same router as the Raspberry Pi.
  2. Open a web browser and go to: https://192.168.1.1.
  3. Log in (default username: root, password: blank).
Step 2: Configure the Internet Connection

  1. Go to Network > Interfaces.
  2. In "LAN," change the IP address to 192.168.2.1 to avoid conflicts.
  3. Save and apply the changes.
  4. Restart the Raspberry Pi and reconnect using the new IP.
  5. Configure the WAN interface to use the internet from the Ethernet cable.
Step 3: Configure WiFi

  1. Go to Network > Wireless.
  2. Enable the wireless network and assign it a name (SSID).
  3. Set a security key (WPA2-PSK).
  4. Save and apply the changes.
  5. Setting Up a SOCKS5 Proxy with Redsocks
Step 1: Install Redsocks

  1. Open a terminal in OpenWRT (you can use SSH with PuTTY).
  2. Run:

opkg update
opkg install redsocks


Step 2: Configure Redsocks

  1. Create the configuration file:

nano /etc/redsocks.conf



nano /etc/redsocks.conf


2. Add the following (modify your SOCKS5 proxy settings):
SH


log_debug = off;
log_info = on;
log = "syslog:daemon";
daemon = on;
redirector = iptables;
}

redsocks {
local_ip = 0.0.0.0;
local_port = 12345;
ip = PROXY_IP;
port = PROXY_PORT;
type = socks5;
}



3. Save and exit (CTRL + X, then Y and ENTER).


Step 3: Start and Enable Redsocks

/etc/init.d/redsocks start
/etc/init.d/redsocks enable


5. Redirect All Traffic Through the Proxy​


  • Step 1: Set Firewall Rules
1. Open the firewall configuration file:
nano /etc/firewall.user

2. Add the following rules:
iptables -t nat -N REDSOCKS
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -i wlan0 -p tcp -j REDSOCKS

3. Save and exit (CTRL + X, then Y and ENTER).
4. Restart the firewall:

/etc/init.d/firewall restart


  1. Testing and Verification
  2. Connect another device to the Raspberry Pi's WiFi network.
  3. Go to https://www.whatismyip.com/ to check if the IP matches the SOCKS5 proxy.
  4. If everything works, all traffic is correctly redirected through the proxy.
Done! My Raspberry Pi is now configured as a router with OpenWRT and Redsocks, so all devices connected to it route their traffic through the SOCKS5 proxy.
 
Top Bottom