I have redsocks working on my Ubuntu laptop but for some reason I cannot get it to work on the OpenWrt router instead.
Here is my setup:
- My LAN is 192.168.1.0/16
- My router is connected to a Wireless Network 192.168.43.1 there is a Socks Proxy on port 1084 on this machine which is the only way to connect to the internet. So configuring Firefox and Chrome to use this proxy works
Redsocks configurationt
// redsocks.conf
// general configuration
base {
redirector = iptables;
}
// for TCP
redsocks {
local_ip = "0.0.0.0"; local_port = "12345";
ip = "192.168.43.1"; port = "60567"; type = socks5;
}
// for UDP, assuming your SOCKS5 proxy supports UDP associate
redudp {
local_ip = "127.0.0.1"; local_port = "12345";
ip = "192.168.43.1"; port = "60567";
dest_ip = "8.8.8.8"; dest_port = "53"; /* set whatever DNS server */
}
My IPTables script
#!/bin/sh
IPTABLES="/usr/sbin/iptables -w5 -t nat"
LISTEN="192.168.1.1"
# create new chain
$IPTABLES -N PROXY
$IPTABLES -I OUTPUT -j PROXY
# exclude local traffic, see: http://manpages.org/ss-redir
$IPTABLES -A PROXY -d 127.0.0.0/8 -j RETURN
$IPTABLES -A PROXY -d 192.168.0.0/16 -j RETURN
#$IPTABLES -A PROXY -d 192.168.43.0/24 -j RETURN
# socksify whole TCP traffic
$IPTABLES -A PROXY -p tcp -j DNAT --to 192.168.1.1:12345
# socksify only DNS UDP traffic
$IPTABLES -A PROXY -p udp --dport 53 -j DNAT --to 192.168.1.1:12345
echo "Ctrl^C to exit."
trap "$IPTABLES -D OUTPUT -j PROXY; $IPTABLES -F PROXY; $IPTABLES -X PROXY" EXIT
# run socksifier
redsocks -c /etc/redsocks.conf