I found articles how to set up a http-proxy. But can't find any info, how to set up a socks5 proxy. My goal is to route all traffic from apps, etc throught this proxy. Is this possible? How then programs like Drony work?


Android does have HTTP proxy support built-in that can be set through Settings and/or command line, but isn't global either and is regarded by proxy aware apps only. However there is no built-in support for SOCKS, so you can't set SOCKS5 proxy from adb shell or terminal emulator without using a third party tool / app.


Proxification has two parts: 1. Establish a connection between client and proxy server. 2. Redirect traffic from whole device or specific apps through proxied connection.

Establishing connection is handled differently by different apps. For instance, SocksDroid uses native tool tun2socks at back end while ProxyDroid uses redsocks. Ki4a also uses tun2socks and has a builtin interface for SSH login to create a Dynamic Forwarding tunnel that acts as a local SOCKS proxy. shadowsocks is another encrypted SOCKS proxy. Other apps like Drony and Postern have their own closed source methods.

Now coming to the redirection part, every app cannot be configured to use proxy, only a few apps, such as web browsers, have native SOCKS support. So again we need to use third party tools.

Redirecting all traffic to a proxy server can also be handled in different ways, two most common methods on Android are iptables (which ProxyDroid uses) and Java VPN API (which SocksDroid, Postern, Drony, Orbot (Tor) and many other apps use). Ki4a and Shadowsocks have both options.

Just as a reference, shared library interceptor concept (used by socksify, tsocks, proxychains etc.) has been a popular SOCKSification hack that - when a dynamic binary is run - loads a library using LD_PRELOAD before any other shared libraries are loaded in memory, hence effectively taking control of syscalls related to networking (connect in particular). But this seems irrelevant on Android.


While configuring all above through command line isn't impossible, it's too complicated to be feasible for a common user. redsocks can be configured with iptables while tun2socks requires creating a tun network interface as well as configuring routing table (that's what VPN API does at back end), which is practically impossible. SSHuttle is also similar project that's based on SSH and makes use of routing table (through tproxy), iptables or PF. ss-redir (shadowsocks) also uses iptables's NAT. Plus, all methods require root access.


So to use SOCKS proxy on Android is best achieved using an app. SocksDroid is simple, free, open source and has no ads. But the selection depends on multiple factors like protocols / methods and one important being the UDP (particularly DNS) support.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.