• January 29, 2023

Linux Global Socks5 Proxy

System wide SOCKS5 Proxy - Unix & Linux Stack Exchange

System wide SOCKS5 Proxy – Unix & Linux Stack Exchange

I connect to my Server on the internet using ssh -D 3128 If I am right I thereby open a SOCKS v5 Proxy to my Server. Using Firefox and FoxyProxy I can now add this to my proxys and tunnel my HTTP-Traffic over it. Howsoever I’d like to use this SOCKS Proxy for all my traffic. Friends told me that they’ve seen this by modifying your route or using iptables howsoever I can’t find anything about it.
intika12. 1k6 gold badges31 silver badges61 bronze badges
asked Aug 3 ’12 at 10:35
SOCKS5 is a protocol (i. e. in the application layer of OSI), so plain network-routing (e. g. via iptables) alone won’t do. (It’s probably necessary, but not sufficient. )
What you need is a proxifier. Without having tried it, tun2socks, allowing you to “socksify TCP at the network layer”, looks promising (as does proxychains, without iptables but prefixing programs explicitly).
(Could socat be used here? This mentions socat for socksifying, but I’m unsure at the moment. )
answered Aug 3 ’12 at 11:37
sr_sr_14. 6k45 silver badges52 bronze badges
1
Proxybound can do the job
To apply it system widely as you asked you can ad it as a default preloaded library, to do so edit /etc/ and add /usr/local/lib/ or depending on how you installed proxybound
After reboot any started application will be preloading proxybound and thus proxified
This method need to be tested carefully because proxybound is not compatible with all the applications you may encounter (resulting in some applications not starting because proxybound does not allow unsupported apps to start, this is to avoid leaks). Alternatively you can setup the env variable LD_PRELOAD with the value /usr/local/lib/ for a specific userspace or user session to limit where proxybound is applied.
answered Apr 28 ’19 at 19:25
intikaintika12. 1k6 gold badges31 silver badges61 bronze badges
Not the answer you’re looking for? Browse other questions tagged arch-linux iptables ssh-tunneling socks route or ask your own question.
How to force all Linux apps to use SOCKS proxy - Super User

How to force all Linux apps to use SOCKS proxy – Super User

for the impatient just do the following; assuming that the proxy is and it’s socks5 (change it with your own later)
first install redsocks sudo apt-get install redsocks, make an empty file anywhere and name it (or whatever), I’ll assume it’s here /etc/ (change it with your own).
edit the file you created () as follows
base {
log_debug = on;
log_info = on;
log = “stderr”;
daemon = off;
redirector = iptables;}
redsocks {
local_ip = 127. 0. 1;
local_port = 12345;
ip =;
port = 7777;
type = socks5;
// known types: socks4, socks5, -connect, -relay
// login = username;
// password = password;}
change 7777 with your proxy,
(note that you can use any local_port other than 12345, 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
sudo redsocks -c /etc/
change with the destination of your
(if you get “bind: Address already in use” try killall redsocks)
you can also check if redsocks is bound to local port 12345 with netstat -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.
sudo iptables -t nat -N REDSOCKS
sudo iptables -t nat -A REDSOCKS -d 0. 0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 10. 0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 127. 0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 169. 254. 0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 172. 16. 0/12 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 192. 168. 0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 224. 0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 240. 0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT –to-ports 12345
sudo iptables -t nat -A OUTPUT -p tcp –dport 443 -j REDSOCKS
sudo iptables -t nat -A OUTPUT -p tcp –dport 80 -j REDSOCKS
sudo iptables -t nat -A PREROUTING -p tcp –dport 443 -j REDSOCKS
sudo iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDSOCKS
now your and traffic should be redirected through
if you want your iptables reset use:
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
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.
Configuring Ubuntu for Global SOCKS5 proxy - Server Fault

Configuring Ubuntu for Global SOCKS5 proxy – Server Fault

what is the best way to configure Ubuntu to use a SOCKS5 proxy for all network traffic? Server is ubuntu server. I want to push all outbound traffic through the proxy (apt-get,,, etc). Everything but ssh should hit the proxy server.
asked Nov 18 ’11 at 17:18
x50x50931 silver badge7 bronze badges
Each command has its own configuration parameters and/or configuration files to use proxy servers. For example, w3m recognizes the HTTP_PROXY environment variable and uses it as a proxy if defined. wget also has options related to proxy settings. apt-get can be configured also to use a proxy server (or better apt-cacher to cache your downloaded packages for future installs/upgrades).
At the very least, you can use iptables to redirect all you outgoing traffic to a specific proxy.
$ sudo iptables -t nat -A OUTPUT -p tcp –dport 80 -j DNAT –to-destination proxy_ip:proxy_port
Adding a rules such as the above is enough to transparently redirect all outgoing traffic to your proxy server. Of course, you can customize the rule according to your needs like forwarding other ports.
answered Nov 18 ’11 at 18:10
KhaledKhaled34. 8k7 gold badges64 silver badges97 bronze badges
Not the answer you’re looking for? Browse other questions tagged proxy ubuntu-10. 04 linux-networking transparent-proxy or ask your own question.

Frequently Asked Questions about linux global socks5 proxy

Leave a Reply

Your email address will not be published. Required fields are marked *