Skip to main content
Scraper API

How to Create a SOCKS5 Proxy Server: Complete Setup Guide for 2026

8 min read

Introduction to Creating a SOCKS5 Proxy Server

As we move into 2025, the need for private, high-performance proxies has grown beyond simple web scraping. Whether you are managing a bot farm, securing corporate traffic, or bypassing geo-restrictions, knowing how to create a SOCKS5 proxy server is a critical skill for network engineers and developers.

Unlike HTTP proxies, which can only handle web traffic (HTTP/HTTPS), a SOCKS5 (Socket Secure 5) proxy operates at the Session Layer (Layer 5) of the OSI model. This allows it to handle any type of traffic, including TCP and UDP, making it superior for applications like torrenting, DNS queries, and email clients (SMTP/IMAP).

Part 1: The Enterprise Standard (Dante Server on Linux)

For a persistent, high-performance setup, nothing beats Dante. It is the industry-standard SOCKS5 server for Unix and Linux systems. Below is a comprehensive guide to setting it up on an Ubuntu 20.04 or 22.04 VPS.

Step 1: Server Preparation

First, ensure your package lists are updated and install the necessary build tools if you are compiling from source (though we recommend the repo version for stability).

Update system

sudo apt update && sudo apt upgrade -y

Install Dante Server

sudo apt install dante-server -y

Step 2: Network Configuration

You need to know your network interfaces. Use ip addr to find them. Typically:

  • Internal: The IP address users connect to.
  • External: The interface used to route traffic to the internet (often eth0 or ens3).
  • Step 3: Configuring danted.conf

    This is the most critical step. Edit the configuration file:

    sudo nano /etc/danted.conf
    

    Below is a production-ready configuration template. It enforces authentication and prevents abuse.

    /etc/danted.conf

    Logging: Essential for debugging and security monitoring

    logoutput: syslog /var/log/danted.log

    The external interface is the one connected to the internet

    external: eth0

    The internal interface is the one clients connect to

    0.0.0.0/0 represents all interfaces, but you can restrict to a specific IP

    internal: 0.0.0.0 port = 1080

    Authentication Method

    'username' requires a valid system user (PAM)

    'none' is insecure and not recommended for public-facing servers

    clientmethod: none socksmethod: username

    Client Access Rules

    Who is allowed to connect to the proxy port?

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

    SOCKS Traffic Rules

    What traffic are allowed users allowed to route through?

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

    Step 4: Creating User Accounts and Firewall

    Dante uses the system's user database for authentication. Do not use the root user.

    Create a proxy user without shell access for security

    sudo adduser --no-create-home --shell /usr/sbin/nologin proxyuser1

    Open the firewall (assuming UFW)

    sudo ufw allow 1080/tcp

    Step 5: Launch and Verify

    Start Dante

    sudo systemctl restart danted

    Check status (ensure it is 'active (running)')

    sudo systemctl status danted

    Part 2: The Quick & Native Method (SSH Tunneling)

    If you already have a Linux server but do not want to install Dante, you can leverage the built-in SSH protocol. This is often called "Poor Man's VPN."

    Creating the Tunnel

    Run this command from your local machine (Linux/Mac/Windows with WSL):

    ssh -D 1080 -N -f user@your_vps_ip
    

  • -D 1080: Tells SSH to create a Dynamic port forward on local port 1080.
  • -N: No remote commands (just port forwarding).
  • -f: Forks the process into the background.
  • Your proxy is now running at 127.0.0.1:1080.

    Part 3: The Developer Approach (Python)

    For custom scraping projects that require rotating proxies or specific header handling, building a lightweight proxy server in Python is a powerful option. While writing a full SOCKS5 implementation from scratch using the socket library is complex, we can use a library like proxy.py or create a basic HTTP tunnel. However, for true SOCKS5 support in Python, PySocks is the standard library.

    Below is a conceptual example of how you might implement a basic TCP forwarder that functions similarly to a proxy using Python's asyncio (modern Python 3.10+ syntax). Note that this is a simplified TCP proxy for demonstration of socket handling; for full SOCKS5 protocol negotiation, you must handle the handshake (Greeting and Request).

    import asyncio
    

    import socket

    Basic concept of an Async Proxy

    class SimpleProxy: def __init__(self, host, port): self.host = host self.port = port

    async def handle_client(self, reader, writer): try: # In a real SOCKS5 server, you would read the initial handshake here # Client -> Proxy: (Version 5, Number of Auth Methods) # Proxy -> Client: (Selected Auth Method)

    # For this example, we assume a direct tunnel connection to a target target_host = 'example.com' target_port = 80

    print(f"Connection from {writer.get_extra_info('peername')}")

    # Connect to the actual destination target_reader, target_writer = await asyncio.open_connection(target_host, target_port)

    async def forward(reader, writer): try: while True: data = await reader.read(4096) if not data: break writer.write(data) await writer.drain() except Exception as e: print(f"Forward error: {e}") finally: writer.close() await writer.wait_closed()

    # Pipe data in both directions task1 = asyncio.create_task(forward(reader, target_writer)) task2 = asyncio.create_task(forward(target_reader, writer)) await asyncio.gather(task1, task2)

    except Exception as e: print(f"Error: {e}") finally: writer.close() await writer.wait_closed()

    async def start(self): server = await asyncio.start_server(self.handle_client, self.host, self.port) addr = server.sockets[0].getsockname() print(f"Serving on {addr}") async with server: await server.serve_forever()

    To run this (uncomment to execute):

    asyncio.run(SimpleProxy('0.0.0.0', 1080).start())

    For a ready-made Python SOCKS5 server solution, it is highly recommended to use established open-source tools like 3proxy or the mini-socks5 package rather than writing the protocol negotiation logic from scratch, as handling UDP ASSOCIATE requests specifically requires strict RFC 1928 compliance.

    Part 4: Windows Implementation

    Windows users often rely on third-party software because the OS lacks a native built-in SOCKS5 server.

    1. 3Proxy: This is a tiny, free proxy server for Windows. It supports SOCKS v4/v5 and HTTP/HTTPS.

  • Download 3proxy.zip.
  • Edit 3proxy.cfg:
  •     nserver 8.8.8.8
    

    timeouts 1 5 30 60 180 1800 15 60 daemon log "C:\logs\3proxy.log" D logformat "- +_L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T" auth strong users admin:CL:admin_password allow admin * * * proxy -n -a -p1080 socks -p1081

  • Run 3proxy.exe.

Comparison: Dante vs. SSH vs. 3Proxy

| Feature | Dante (Linux) | SSH Tunneling | 3Proxy (Windows) | | :--- | :--- | :--- | :--- | | Protocol Support | Full SOCKS5 (TCP/UDP) | Full SOCKS5 (via Dynamic Forward) | Full SOCKS4/5 + HTTP | | Authentication | Username/PAM | SSH Keys / Password | Username/Password (Internal) | | Configuration | Moderate (Config Files) | Simple (One-liner) | Moderate (Config Files) | | Performance | High (Native C) | Medium (Encrypted Overhead) | Medium/High | | Use Case | Dedicated Proxy Server | Personal Browsing / Dev | Windows Services |

Security Hardening for 2025

Creating the server is easy; securing it is where experts earn their money.

1. Prevent Open Proxy Abuse: Never run a proxy without authentication (method: none) on a public IP. You will be hijacked for spam or illegal activity within hours. 2. Geo-Fencing: Configure Dante or use iptables to only allow connections from specific IP ranges (e.g., your office IPs). 3. UDP Limitations: Be aware that while SOCKS5 supports UDP (via the ASSOCIATE command), Dante and many firewalls handle UDP differently than TCP. Ensure your kernel allows UDP forwarding if you need DNS over SOCKS5.

By following these steps, you can deploy a robust, private SOCKS5 infrastructure suitable for high-volume scraping or secure tunneling in 2025.

Share: