Hold Tight...

0 %
Driving cybersecurity excellence
Innovator behind Kodachi OS
  • Residence:
    ::0
  • Uptime Binary:
    110001
  • Mantra:
    Innovate, Secure, Repeat
ONS
EEDS
NSSG
Cybersecurity
Programming & R&D
Cryptocurrency
AI & vibe coding
  • Bash
  • Gambas
  • Delphi
  • PHP
  • Visual Basic
  • Rust

Effortlessly Deploy a Dante SOCKS5 Proxy with This Bash Script

03/11/2024
3 min readDeep Tech4 code examplesUpdated October 2026

Key points

  • A Bash script that installs the Dante SOCKS5 server, finds your network interface, writes /etc/danted.conf and starts the service on port 4004.
  • As written it makes an open proxy (no password, any address): lock it down with the lines in the update before you start it.
  • SOCKS5 encrypts nothing, so carry private traffic over SSH or a VPN.

Simplify Your Dante SOCKS5 Proxy Setup with This Bash Script

Updated October 2026: Read this before you run the Dante SOCKS5 proxy setup script. The configuration it writes accepts connections from any address without a password (clientmethod: none, socksmethod: none and from: 0.0.0.0/0), which makes the server an open proxy. Scanners find open SOCKS proxies quickly and use them for spam and attacks, and your hosting provider will hold you responsible. Before you start danted, lock it down:

  • Limit the client pass and socks pass rules to your own address and require a login with a dedicated system user that has no login shell (the exact lines are below).
  • Allow port 4004 only from your own address in the firewall (ufw or nftables).
  • SOCKS5 does not encrypt anything, and its username and password travel in clear text, so use it inside an SSH tunnel or a VPN when the network is not trusted.
  • Port 4004 is above 1024, so the setcap step is not needed for the default port.
  • The script appends its block to /etc/danted.conf; check the file afterwards for older settings that conflict with it.
# /etc/danted.conf: replace "socksmethod: none" with these three lines
socksmethod: username
user.privileged: root
user.unprivileged: nobody

# put your own address in both "from:" lines (203.0.113.10 is an example)
# and delete the two ::/0 blocks unless you add your IPv6 address there
client pass {
    from: 203.0.113.10/32 to: 0.0.0.0/0
    log: error
}
socks pass {
    from: 203.0.113.10/32 to: 0.0.0.0/0
    log: error
}

# create a proxy login without a shell, then restart Dante
useradd -r -s /usr/sbin/nologin proxyuser
passwd proxyuser
systemctl restart danted

Setting up a Dante SOCKS5 proxy on a Debian-based system can be complex, especially for those unfamiliar with network configurations. This Bash script automates the installation and configuration process, making it easier than ever to deploy a SOCKS5 proxy server. Lock it down as described above before you open it to the internet.

What Is Dante?

Dante is a versatile SOCKS5 proxy server that allows clients to route their network traffic through a proxy (SOCKS5 itself does not encrypt that traffic). It’s widely used for enhancing privacy, bypassing network restrictions, and managing traffic in various environments.

Key Features of the Script

  • Uses sudo: Runs the privileged steps with sudo, so run it as root or as a user with sudo rights.
  • Automatic Installation: Installs the Dante server if it’s not already present on the system.
  • Network Interface Detection: Automatically identifies the primary network interface for accurate proxy configuration.
  • Configuration Management: Updates the Dante configuration file to set up the SOCKS5 proxy on the specified port.
  • Port Binding: Applies setcap so that Dante can bind to a port below 1024 without root (not needed for the default port 4004).
  • Service Management: Restarts the Dante service to apply the new configurations seamlessly.

How It Works

  1. Checks for Dante Installation: Ensures Dante is installed on your system. If not, the script installs it using the package manager.
  2. Detects Network Interface: Identifies the primary network interface to configure Dante correctly.
  3. Configures Dante: Updates the /etc/danted.conf file with proxy settings, including the specified port and allowed traffic rules.
  4. Sets the Port Capability: Uses setcap to grant Dante the ability to bind to privileged ports (below 1024).
  5. Manages the Service: Restarts the Dante service to apply configurations and ensures it is active.
  6. Reports the Result: Prints a message when the setup is complete. To confirm that Dante is listening, run ss -ltnp | grep 4004.

Quick Start

  1. Save and Make Executable: copy the full script at the end of this post into a file named dante-setup.sh, then run:
   chmod +x dante-setup.sh
  1. Run the Script:
   sudo ./dante-setup.sh
  1. Let It Run: Let the script handle installation, configuration, and service setup.
  1. Access Your Proxy: Your SOCKS5 proxy server will be accessible on the specified port (default: 4004).

Benefits

  • Time-Saving: Automates a complex multi-step process.
  • Security Note: The configuration is open to every address; restrict it as described at the top of this post before you expose the port.
  • Ease of Use: Handles installation, configuration, and service management in a single script.
  • Versatility: Ideal for bypassing network restrictions, enhancing privacy, and managing traffic.

Conclusion

This Bash script takes the complexity out of setting up a Dante SOCKS5 proxy server. With automated installation and configuration, you can deploy an efficient proxy server in minutes. Simplify your networking tasks and enjoy enhanced privacy and control with this powerful tool! More of my server scripts are in Deep Tech.

ShellScript
#!/bin/bash
# =========================================
# Dante Server Setup Script
# =========================================
#
# Version: 1.0.0
# Script written by Warith AL Maawali
#
# Discord channel: https://discord.gg/KEFErEx
# Twitter: https://x.com/warith2020
# Linkedin: https://www.linkedin.com/in/warith1977
# Website: https://www.digi77.com
# (c) 2024
#
# Description:
# This script installs and configures the Dante server for SOCKS5 proxy on a Debian-based system.
# It ensures root privileges, installs the Dante server if not already installed, auto-detects the network interface,
# and configures the Dante server to listen on the specified port.
#
# This software is dual-licensed:
#
# Personal, non-commercial use: Apache License 2.0
# Commercial, corporate, or organizational use: Separate commercial license required.
# Contact me for licensing inquiries.
#
# Usage: ./dante-setup.sh
#
# Usage Examples:
#   Run this script as root to install and configure the Dante server:
#     ./dante-setup.sh
# =========================================

dante_port=4004

# Check if Dante server is already installed
if ! command -v danted &>/dev/null; then
  echo "Installing Dante server..."
  sudo apt update
  sudo apt install -y dante-server
else
  echo "Dante server is already installed."
fi

# Auto-detect the network interface
interface=$(ip -o -4 route show to default | awk '{print $5}')

# Check if the configuration file exists and contains the specified port
if ! grep -q "port = $dante_port" /etc/danted.conf; then
  echo "Configuring Dante for SOCKS5 on port $dante_port..."
  bash -c "cat <<EOF >> /etc/danted.conf
logoutput: syslog
internal: 0.0.0.0 port = $dante_port
internal: :: port = $dante_port
external: $interface

clientmethod: none
socksmethod: none

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

client pass {
    from: ::/0 to: ::/0
    log: error
}

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

socks pass {
    from: ::/0 to: ::/0
    log: error
}
EOF"
  danted_path=$(which danted)
  if [ -n "$danted_path" ]; then
    # Use readlink to get the original file path if it's a symlink
    real_danted_path=$(readlink -f "$danted_path")

    if [ -n "$real_danted_path" ]; then
      echo "Applying setcap to $real_danted_path"
      sudo setcap 'cap_net_bind_service=+ep' "$real_danted_path"
    else
      echo "Failed to resolve the real path for danted"
      exit 1
    fi
  else
    echo "Error: danted not found in PATH"
    exit 1
  fi

  # Restart Dante to apply changes
  sudo systemctl restart danted
  echo "Dante SOCKS5 proxy setup complete on port $dante_port."
else
  echo "Dante is already configured correctly."
fi
ShellScript
Posted in Deep TechTags: