Using Linux, I need a way to route all network traffic of interface enp2s0 through SOCKS4 192.168.1.2:1080 (or any SOCKS proxy for that matter)
– something like Proxifier in Windows.
The proxy works fine when manually set in Chrome or Firefox.
OS:
Linux Mint 19.1
Things I tried:
-
I set the proxy manually in network settings,
but it's just like I didn't set it;
Chrome still connects directly. Here's a screenshot:
-
Proxychains is working great,
but I have to manually launch each app individually from the terminal.
I don't know how to use redsocks or iptables (yet).
I hope there's a GUI like Proxifier for Linux,
but a terminal (CLI)-based solution is okay.
Best Answer
for the impatient just do the following; assuming that the proxy is
example.com:7777
and it's socks5 (change it with your own later)sudo apt-get install redsocks
, make an empty file anywhere and name it redsocks.conf (or whatever), I'll assume it's here
/etc/redsocks.conf
(change it with your own).change
example.com
7777
with your proxy, (note that you can use anylocal_port
other than12345
,it's the local port that we will set an iptable rule to redirect the traffic to, so if you use another, make sure to use it in later steps below)-- now run redsocks with the config file destination as follows
change with the destination of your redsocks.conf (if you get "bind: Address already in use" try
killall redsocks
) you can also check if redsocks is bound to local port 12345 withnetstat -tulpn
-- now that redsocks is running and ready, let's change the iptables rules to use redsocks. this should be customized to your needs, but if you like to redirect all HTTP and HTTPS packets through the proxy. Define the following rules.
now your http and https traffic should be redirected through
example.com:7777
if you want your iptables reset use:
additional tip: if you have vpn on your iphone or android, you can use it for free in your pc whatever the OS is. just connect the phone vpn app, and establish a socks proxy server ( in android you can use 'servers ultimate' app) then use the proxy in your pc as above, now all your pc traffic is routed through your phone vpn. neat.