How to setup a Socks5 Proxy server on Ubuntu with Dante

Dante Socks5 Server

Dante is a socks5 server that you can use to setup a socks5 proxy on your ubuntu or debian machine. In this quick tutorial we shall learn how to setup dante and use authentication.

With authentication enabled, the dante proxy server would require all clients to provide login details in order to use the proxy server. This is a good idea.

Installing Dante on Ubuntu

The default Ubuntu repositories have the dante-server package but it is outdated. The version present is 1.1.19 which is quite old and also has some bugs. The authentication feature does not work properly.

If you don't need authentication then you can install it.

sudo apt-get install dante-server

The version in repository was

# danted -v
danted: dante v1.1.19

Like said earlier, the authentication feature does not properly work with it. The log file shows the following error messages -

Mar 11 14:05:05 (1489241105) danted[5020]: pass(1): tcp/accept ]: username%[email protected] -> 104.131.115.128.1080: system username/password failed

Trying to test with curl shows the following error message -

$ curl -v -x socks5://username:[email protected]:1080 http://www.google.com/
*   Trying 104.131.115.128...
* User was rejected by the SOCKS5 server (1 1).
* Closing connection 0
curl: (7) User was rejected by the SOCKS5 server (1 1).

Some users have reported similar issues at this reddit post -https://www.reddit.com/r/techsupport/comments/3qu9a4/dante_proxy_server_authentication_failing/

So we need to install a newer version. There is a ppa for dante-server at - https://launchpad.net/~dajhorn/+archive/ubuntu/dante

but it is no longer being maintained. But we can use the deb file from the ppa to install dante on Ubuntu 16.10

The download url is this -

http://ppa.launchpad.net/dajhorn/dante/ubuntu/pool/main/d/dante/dante-server_1.4.1-1_amd64.deb
# wget http://ppa.launchpad.net/dajhorn/dante/ubuntu/pool/main/d/dante/dante-server_1.4.1-1_amd64.deb

Install using gdebi command

$ sudo apt-get install gdebi-core
$ sudo gdebi dante-server_1.4.1-1_amd64.deb

Configure

The next task is to configure the dante server before starting it. The configuration file can be found here -

nano /etc/danted.conf

The contents should look similar to this -

# /etc/danted.conf

logoutput: syslog
user.privileged: root
user.unprivileged: nobody

# The listening network interface or address.
internal: 0.0.0.0 port=1080

# The proxying network interface or address.
external: eth0

# socks-rules determine what is proxied through the external interface.
# The default of "none" permits anonymous access.
socksmethod: username

# client-rules determine who can connect to the internal interface.
# The default of "none" permits anonymous access.
clientmethod: none

client pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
        log: connect disconnect error
}

socks pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
        log: connect disconnect error
}





Now start the danted proxy server

# service danted start

Use the netstat command to check the port number

# netstat -nlpt | grep dant
tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      6342/danted

Create a User

Dante can use the system unix user accounts to authenticate the connecting clients. For this you should create a separate user. Any client that will be connecting to this proxy server will be sending the password in plain text over the network, so beware of that.

$ adduser mike

Test with curl

Once you have setup everything, its time to test that the proxy server is working as expected. Use the curl command to do this. Specify the username, password, server ip and port number and try fetching some url.

curl -v -x socks5://mike:[email protected]<PROXY_IP>:1080 http://www.google.com/

If everything goes fine, you should see the html of google.com in the terminal. Now you can use the proxy inside of browsers.

Resources

Config documentation can be found here -
https://www.inet.no/dante/doc/1.4.x/config/server.html

If you want to compile the latest version of dante from source then check out these links -

http://www.nat.li/linux/how-to-install-dante-on-linux
http://tazdij.com/post/setup-dante-1.4.1-sockd-dante-server-on-ubuntu-16.04

Last Updated On : 12th March 2017

Subscribe to get updates delivered to your inbox

Leave a comment