Skip to content

Instantly share code, notes, and snippets.

@gpchelkin
Last active August 22, 2023 06:45
Show Gist options
  • Save gpchelkin/c7d24a21639d1f120fb082d1801a5fe4 to your computer and use it in GitHub Desktop.
Save gpchelkin/c7d24a21639d1f120fb082d1801a5fe4 to your computer and use it in GitHub Desktop.
How to Setup SOCKS5 Proxy Server for (not only) Telegram using Dante on Ubuntu 16.04 / 18.04 / 20.04
### NOT A SCRIPT, JUST A REFERENCE!
# install dante-server
sudo apt update
sudo apt install dante-server
# or download latest dante-server deb for Ubuntu, works for 16.04 / 18.04 / 20.04:
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/dante/dante-server_1.4.2+dfsg-7build5_amd64.deb
# or older version:
wget http://ppa.launchpad.net/dajhorn/dante/ubuntu/pool/main/d/dante/dante-server_1.4.1-1_amd64.deb
# and install it:
sudo dpkg -i dante-server_*.deb
# it may fail to start, it's okay, packaged config is garbage
# open dante config for editing:
sudo nano /etc/danted.conf
# remove everything (holding Ctrl+K will do it) and copy-paste basic config:
logoutput: syslog
user.privileged: root
user.unprivileged: nobody
# desired proxy ports may differ, used here: POP3 110, IMAP 143, HTTPS 443
internal: 0.0.0.0 port = 110
internal: 0.0.0.0 port = 143
internal: 0.0.0.0 port = 443
# interface name may differ, use `ip a` command and copy non-lo interface:
external: eth0
# set socksmethod to 'none' instead of 'username' if you want to disable auth.
socksmethod: username
clientmethod: none
user.libwrap: nobody
client pass {
from: 0/0 to: 0/0
log: connect disconnect error
}
socks pass {
from: 0/0 to: 0/0
log: connect disconnect error
}
# end of config
# add system user 'proxyuser' with password to use with sock5 auth:
sudo useradd --shell /usr/sbin/nologin proxyuser
# or:
# sudo adduser --system --no-create-home --disabled-login --group proxyuser
sudo passwd proxyuser
# and input desired password twice
# if you use ubuntu firewall, allow ports:
sudo ufw allow 110
sudo ufw allow 143
sudo ufw allow 443
# restart dante and enable starting on boot:
sudo systemctl restart danted
sudo systemctl enable danted
# you may see dante status:
sudo systemctl status danted
# you may see dante logs (connect disconnect error):
sudo journalctl -xe -u danted
# add -f argument to attach and watch
# test proxy on your local machine:
curl -v -x socks5://proxyuser:password@yourserverip:443 https://www.yandex.ru/
# construct telegram links:
# https://t.me/socks?server=yourserverip&port=443&user=proxyuser&pass=password
# tg://socks?server=yourserverip&port=443&user=proxyuser&pass=password
# used and useful links:
# http://www.inet.no/dante/doc/latest/config/server.html
# http://www.inet.no/dante/doc/latest/config/redundancy.html
# https://www.binarytides.com/setup-dante-socks5-server-on-ubuntu/
# https://krasovsky.me/it/2017/07/socks5-dante/
# https://bitbucket.org/snippets/gudvinr/qd5pA
@howdiw
Copy link

howdiw commented Aug 15, 2019

Hello there and thanks for sharing this article,
everything is good, but my network is not eth0 ( is ens160 ), I replaced it.

also when I type this command:
sudo systemctl restart danted
I face with this error:
Job for danted.service failed because the control process exited with error code. See "systemctl status danted.service" and "journalctl -xe" for details.

It seems that there are some problems on dante.service, for more detail, I read a help in StackOverFlow, when I type these commands:
sudo systemctl daemon-reload
sudo systemctl enable danted.service
I face with this error:
danted.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable danted

I also searched this problem on google, there were some solves, but no one worked!
Could you please help me?

@TheMehranKhan
Copy link

Thanks for the Tutorials :) I'm having a little bug with connecting to my proxy.
Everything works and the CURL tests give me the right response but telegram can't connect to this proxy.
Anyone having any idea why this is happening?

@NetAfarin
Copy link

Thanks for the Tutorials :) I'm having a little bug with connecting to my proxy.
Everything works and the CURL tests give me the right response but telegram can't connect to this proxy.
Anyone having any idea why this is happening?

I have same problem with Telegram

@yoursbest
Copy link

Good gist! I followed the guide and had Dante 1.4.2 running on my Ubuntu 16.04 smoothly!

@ali-tafakkori
Copy link

Thanks for the Tutorials :) I'm having a little bug with connecting to my proxy.
Everything works and the CURL tests give me the right response but telegram can't connect to this proxy.
Anyone having any idea why this is happening?
I have same problem with Telegram in android

@fakhamatia
Copy link

When I set socksmethod: none proxy not working
Or when set socksmethod: none username only with auth works

@RMS21
Copy link

RMS21 commented Dec 3, 2020

I use this configuration but I get the error
negotiate timeout after 31 seconds
can anyone help?

@harryqt
Copy link

harryqt commented Dec 6, 2020

Worked perfectly on Ubuntu 20.04. Thanks.

@mohsen-hassani
Copy link

Awsome. Thanks

@hamedniroomand
Copy link

Thanks for the Tutorials :) I'm having a little bug with connecting to my proxy.
Everything works and the CURL tests give me the right response but telegram can't connect to this proxy.
Anyone having any idea why this is happening?

I have same problem with Telegram

@szalony9szymek
Copy link

hi, how do I use a different network interface for ipv6 and for ipv4?

@DevilLord41
Copy link

Hi, im using alibabacloud for this.
I have used socks5 for this, and when i connect, it connect to my private primary ip instead of public ip, how do it fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment