
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.
- 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
- Installing OpenWRT on the Raspberry Pi
- Go to the official OpenWRT website: https://openwrt.org/
- Find the version compatible with Raspberry Pi 3 and download the image (.img.gz).
- Use a tool like Rufus or Balena Etcher.
- Insert the microSD card into your computer.
- Select the OpenWRT image and the microSD card.
- Click on "Flash" or "Write" and wait for it to finish.
- Insert the microSD card into the Raspberry Pi.
- Connect it to the router with the Ethernet cable.
- Turn it on and wait for it to boot.
- Configuring OpenWRT
- On your computer, connect to the same router as the Raspberry Pi.
- Open a web browser and go to: https://192.168.1.1.
- Log in (default username: root, password: blank).
- Go to Network > Interfaces.
- In "LAN," change the IP address to 192.168.2.1 to avoid conflicts.
- Save and apply the changes.
- Restart the Raspberry Pi and reconnect using the new IP.
- Configure the WAN interface to use the internet from the Ethernet cable.
- Go to Network > Wireless.
- Enable the wireless network and assign it a name (SSID).
- Set a security key (WPA2-PSK).
- Save and apply the changes.
- Setting Up a SOCKS5 Proxy with Redsocks
- Open a terminal in OpenWRT (you can use SSH with PuTTY).
- Run:
opkg update
opkg install redsocks
Step 2: Configure Redsocks
- 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
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
- Testing and Verification
- Connect another device to the Raspberry Pi's WiFi network.
- Go to https://www.whatismyip.com/ to check if the IP matches the SOCKS5 proxy.
- If everything works, all traffic is correctly redirected through the proxy.