Last active
February 6, 2025 08:58
-
-
Save WMAL/fd5bc4d2843a033588219cdb5f47060f to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: ./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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment