How to setup a Socks5 Proxy server on Ubuntu with Dante

By | May 4, 2023

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.

1. Install 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

Known authentication issues

Like mentioned 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:password@IP: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/

Install newer version directly from .deb file

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

Download using the wget command:

# 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

2. 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

3. 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

4. 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:mike@<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.

Conclusion

Dante is a socks5 server that can be used as a proxy server. For instance you can setup an online linux server and use it as a proxy server to access other websites. Such proxy servers are useful when you need to change your ip address on the internet or access a website from a different geo location.

If you need an http proxy server or caching solution try Squid Proxy which supports http, https etc.

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

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

7 Comments

How to setup a Socks5 Proxy server on Ubuntu with Dante
  1. Gerardo Sandrigam

    Hello Friends I just install Dante Socks 1.4.02 version of Dante on Virtual Machine of my Pc with Virtual Box and Red Hat 8.3 , I finally finally I got the service to work but how can I do a test with user and password to port 1080 that I already configure in the sockd.conf file

    Regards

  2. Null

    This guide is great but the service doesn’t start on boot even though it shows as enabled in systemctl, also creating a time delayed @reboot sleep 30 && service danted restart also does nothing. Nobody at my work can figure out how to get it to start on boot either, only seems to work with a manual sudo service danted start. Any help would be appreciated as a whole room of people are stumped.

  3. Sinai

    Hi there, I followed your instructions on this article. But when I want to start the service I get the following error:
    error: /etc/danted.conf: problem on line 22 near token “0.0.0.0”: syntax error.

    here’s my configuration:
    # /etc/danted.conf

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

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

    # The proxying network interface or address.
    external: ens18

    # 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: error
    }

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

    The Operating System is Ubuntu 16.04

  4. Alexey

    Is there any way to limit connections for user? Going to create logins for friends and limit with 2-3 connections simultaneously to prevent sharing logins with everybody.

Leave a Reply

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