Sometimes we installed a proxy server, but only certain programs such as Firefox and Google chrome provide proxy settings. Luckily, we can use a command line utility called proxychains to redirect any program to go through our proxy server. This tutorial will show you how to set it up on Debian, Ubuntu, OpenSUSE, Fedora, CentOS/Redhat, Arch Linux and their derivatives.
If your don’t know how to set up a proxy server, then check out this post to learn the merits of shadowsocks proxy. After that, come back here.
Debian/Ubuntu/Linux Mint/Elementary OS
sudo apt-get install proxychains
OpenSUSE Leap 42.1
proxychains is available from the packman repository.
sudo zypper install proxychains
sudo dnf install proxychains
sudo yum install proxychains
sudo pacman -S proxychains-ng
On kali linux, proxychains is installed by default.
Add a Proxy Server to Proxychains
Open the configuration file.
sudo nano /etc/proxychains.conf
At the end of the file, add your proxy like this
socks5 127.0.0.1 1080
socks5 is the proxy type, you can add other types as well such as http, https, socks4 etc. depending on your situation. 127.0.0.1 is the proxy host, and 1080 is the port on which proxy server listens. Again, change them to your specific situation.
The default proxy is
socks4 127.0.0.1 9050 which you can safely remove.
Set a Default DNS Server
It’s highly recommended that you change the default 18.104.22.168 DNS server to something else, such as Google’s DNS server 22.214.171.124/126.96.36.199. Or OpenDNS server 188.8.131.52/184.108.40.206. Open the resolv configuration file.
sudo nano /usr/lib/proxyresolv
Linux Mint/Elementary OS
sudo nano /usr/lib/proxychains3/proxyresolv
sudo nano /usr/bin/proxyresolv
Find the following line
Change its value to something like 220.127.116.11. Then save and close the file. On Arch Linux, there’s no proxyresolv config file.
Just prepend proxychains to any command you execute like the following.
proxychains youtube-dl -citw https://www.youtube.com/channel/<channel-id>
If you are using youtube-dl then you may know that it has not built-in support for socks proxy, but Proxychains will redirect youtube-dl to go through the proxy server.
If you want to redirect all your terminal traffic through proxy server, then enter start a new shell program with proxychains, like below.
This command will start another bash shell with proxychains in your terminal and from now on you don’t have to prepend proxychains to your command. Your traffic in this new shell will be automatically redirected through proxy server.
Note: Terminal is different from shell. Terminal is the device that enable you to connect to a host computer whereas shell is a piece of software on the host computer. Shell is a command line interpreter, translating your command to zeros and ones so the computer can understand your command. When a terminal connects to a host computer, a shell program will be automatically started so that the user’s commands can be interpreted by the shell and the computer can understand the user’s commands.
By default, proxychains will output its activity to the terminal. If you don’t want to see this information, then you can disable it by editing
sudo nao /etc/proxychains.conf
Find the following line
Remove the hashtag. Save and close the file. Now you will only see the output of the application that is being redirected.