linuxuser34
New Member
Hello!
I want to route all traffic through redsocks proxy using iptables.
My redsocks.conf:
Proxy works fine.
My iptables rules:
Also, ipv4 forward enabled.
In local machine (M1) routing works ok, I can access HTTP websites (80 port) through my socks5 proxy.
But it doesn't work from other machine (M2) which is connected to M1 with redsocks through gateway.
I get error: curl: (7) Failed to connect to *host* port 80: Connection refused.
Also, if I delete PREROUTING rule, routing will work from both machines, but M2 will work without proxy, just connect to the Internet directly.
What am I doing wrong?
Thanks in advance!
I want to route all traffic through redsocks proxy using iptables.
My redsocks.conf:
Code:
base {
log_debug = on;
log_info = on;
log = "file:/home/user/redsocks.log";
daemon = on;
redirector = iptables;
}
redsocks {
local_ip = 127.0.0.1;
local_port = 2525;
ip = *proxy ip*;
port = *proxy port*;
login = *proxy login*;
password = *proxy password*;
type = socks5;
}
Proxy works fine.
My iptables rules:
Code:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 2525 # Route incoming traffic through redsocks.
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 2525 # Route local traffic through redsocks.
sudo iptables -t nat -A POSTROUTING -p tcp -o enp0s3 -j MASQUERADE # Route all traffic through enp0s3 interface.
Also, ipv4 forward enabled.
In local machine (M1) routing works ok, I can access HTTP websites (80 port) through my socks5 proxy.
But it doesn't work from other machine (M2) which is connected to M1 with redsocks through gateway.
I get error: curl: (7) Failed to connect to *host* port 80: Connection refused.
Also, if I delete PREROUTING rule, routing will work from both machines, but M2 will work without proxy, just connect to the Internet directly.
What am I doing wrong?
Thanks in advance!