Redsocks proxy - DNS issues

opalman

Newbie
Joined
Apr 12, 2023
Messages
14
Reaction score
23
Hi all, I'm trying to funnel specific devices through a proxy connected to my router, but am having trouble funneling the DNS queries through. The aim is to have multiple phones connected to this router, and allow certain devices to use the proxy connection, whilst leaving my PC on the repeated wifi connection. We do not want to have any VPN/proxy configurations on a phone level.

Setup
iProxy (mobile data sim)
GL-MT3000 Beryl AX router (openwrt, Redsocks installed) - Connected to home WiFi
iPhones

Using the below config and iptables, I'm able to allow my iphone (local ip 192.168.8.153) to use the proxy connections for tcp traffic (I can see the Proxy public ip and no webrtc leaks, but can still see my wifi DNS).

redsocks.conf
base {
log_debug = on; log_info = on;
log = "syslog:local7";
daemon = on;
redirector = iptables;
}
redsocks {
local_ip = 0.0.0.0; local_port = 12345;
ip = iproxy ip; port = iproxy port; type = socks5; login = "iproxy username"; password = "iproxy password";
}
redudp {
local_ip = 127.0.0.1; local_port = 10053;
ip = iproxy ip; port = iproxy port; type = socks5; login = "iproxy username"; password = "iproxy password";

dest_ip = 8.8.8.8; dest_port = 53;
udp_timeout = 30;
udp_timeout_stream = 180;
}
dnstc {
local_ip = 127.0.0.1; local_port = 5300;
}

Iptables
# Resetting to default
iptables -t nat -F
iptables -F
iptables -t mangle -F
iptables -t raw -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Allowing local Wifi connections
iptables -t nat -A POSTROUTING -o apcli0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o apclix0 -j MASQUERADE
iptables -A FORWARD -i br-lan -o apcli0 -j ACCEPT
iptables -A FORWARD -i apcli0 -o br-lan -j ACCEPT
iptables -A FORWARD -i br-lan -o apclix0 -j ACCEPT
iptables -A FORWARD -i apclix0 -o br-lan -j ACCEPT

# Funelling iPhones traffic through Redsocks
iptables -t nat -N REDSOCKS
iptables -t nat -A PREROUTING -s 192.168.8.153 -p tcp -j REDSOCKS
iptables -t nat -A PREROUTING -s 192.168.8.153 -p udp -j REDSOCKS

iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN

iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-port 12345
iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-port 12345

# Restarting to update config
service redsocks restart
service redsocks start

I've tried targeting udp ports by using iptables like "iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-port 5300" but still no luck - has anyone been able to use Redsocks in a similar setup to me and successfully funnel all DNS through your proxy? Thanks!
 
not sure if the information I provided will be helpful, but I encourage you to try the suggestions I outlined.

Check Redsocks Configuration: Ensure that the Redsocks configuration file (redsocks.conf) is correct. Verify that the settings for the proxy server (IP address, port, username, and password) are accurate. Additionally, check if the redudp section is configured properly, including the dest_ip and dest_port for the DNS server.

Adjust IPTables Rules: Review the IPTables rules you've implemented. Make sure that the rules are correctly capturing and redirecting both TCP and UDP traffic from your iPhone to Redsocks. Double-check the port numbers and IP addresses specified in the rules.

Check Firewall Settings: Verify that your router's firewall is not blocking or interfering with the Redsocks or IPTables configurations. Ensure that the necessary ports (e.g., 12345 for TCP and 5300 for DNS) are open and accessible.
 
Back
Top