Simplify Your Dante SOCKS5 Proxy Setup with This Bash Script
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 secure SOCKS5 proxy server.
What is Dante?
Dante is a versatile SOCKS5 proxy server that allows clients to securely route their network traffic through a proxy. It’s widely used for enhancing privacy, bypassing network restrictions, and managing traffic in various environments.
Key Features of the Script
- Root Privileges Check: Ensures the script is executed with the necessary administrative permissions.
- 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.
- Security Enhancements: Applies
setcap
to allow Dante to bind to privileged ports without running as root. - Service Management: Restarts the Dante service to apply the new configurations seamlessly.
How It Works
- Checks for Dante Installation:
- Ensures Dante is installed on your system. If not, the script installs it using the package manager.
- Detects Network Interface:
- Identifies the primary network interface to configure Dante correctly.
- Configures Dante:
- Updates the
/etc/danted.conf
file with proxy settings, including the specified port and allowed traffic rules.
- Enhances Security:
- Uses
setcap
to grant Dante the ability to bind to privileged ports while running with reduced permissions.
- Manages the Service:
- Restarts the Dante service to apply configurations and ensures it is active.
- Verifies Configuration:
- Confirms that Dante is correctly configured and running on the specified port.
Quick Start
- Download and Make Executable:
chmod +x dante-setup.sh
- Run the Script:
sudo ./dante-setup.sh
- Follow Prompts:
- Let the script handle installation, configuration, and service setup.
- 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.
- Enhanced Security: Configures Dante with modern best practices for secure operation.
- 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 a secure and efficient proxy server in minutes. Simplify your networking tasks and enjoy enhanced privacy and control with this powerful tool!
#!/bin/bash
# =========================================
# Dante Server Setup Script
# =========================================
#
# Version: 1.0.0
# Script written by Warith AL Maawali
#
# Discord channel: https://discord.gg/KEFErEx
# Twitter: http://twitter.com/warith2020
# Linkedin: http://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: ./danate-setup.sh
#
# Usage Examples:
# Run this script as root to install and configure the Dante server:
# ./danate-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