Email
Enterprise Service
menu
Email
Enterprise Service
Submit
Basic information
Waiting for a reply
Your form has been submitted. We'll contact you in 24 hours.
Close
Home/ Blog/ How to build Socks5 proxy on Linux system? Detailed Tutorial

How to build Socks5 proxy on Linux system? Detailed Tutorial

Author:PYPROXY
2025-01-10

In today's digital world, privacy and security are paramount. One way to achieve both is by using a socks5 proxy, which allows users to route internet traffic through a remote server, ensuring anonymity and providing secure access to restricted resources. Setting up a SOCKS5 proxy on a Linux system is relatively simple and can be done with a few key steps. This guide will walk you through the process of configuring a SOCKS5 proxy on Linux, detailing each step and providing clear explanations to ensure you can securely establish and use this proxy service for your online activities.

Understanding SOCKS5 Proxy

Before diving into the setup process, it's important to understand what a SOCKS5 proxy is and why it can be beneficial. SOCKS (Socket Secure) is a protocol that routes network packets between a client and server through a proxy server. SOCKS5 is the latest version, offering several enhancements over its predecessors.

Unlike HTTP proxies, which only handle web traffic, SOCKS5 supports a broader range of protocols, including UDP, making it a versatile choice for users needing secure, high-performance connections for a variety of applications. Whether you're accessing a restricted website or using peer-to-peer protocols, a SOCKS5 proxy ensures your data is routed through an encrypted server, masking your IP address.

Prerequisites

Before beginning the setup process, there are a few prerequisites you need to ensure your Linux system is ready:

1. A Linux-based system: This guide assumes you are working on a distribution like Ubuntu, Debian, CentOS, or Fedora.

2. Root or sudo access: You will need administrator privileges to install necessary software and configure the system.

3. A server for hosting the SOCKS5 proxy: This could either be a physical machine, a cloud instance, or any server that you can access remotely.

4. Firewall and network settings: Ensure that your firewall is configured to allow the necessary traffic on the port used for the SOCKS5 proxy.

Step 1: Installing the Required Software

To set up a SOCKS5 proxy on Linux, you first need to install the necessary software. A popular choice is Dante, a free SOCKS server that supports both SOCKS4 and SOCKS5 protocols.

On Ubuntu/Debian:

```bash

sudo apt update

sudo apt install dante-server

```

On CentOS/Fedora:

```bash

sudo yum install dante-server

```

Dante is a powerful tool for creating secure socks5 proxies and provides good flexibility in configuration. Once the installation is complete, you can proceed with the configuration process.

Step 2: Configuring the Dante Server

After installation, the next step is to configure the Dante server. The configuration file is typically located at `/etc/danted.conf`. This file will dictate how the server operates, including the IP addresses and ports it listens to, as well as authentication methods.

Open the configuration file for editing:

```bash

sudo nano /etc/danted.conf

```

Here’s an example of a basic configuration:

```

logoutput: /var/log/danted.log

internal: 0.0.0.0 port = 1080

external: eth0

method: username none

user.privileged: root

user.unprivileged: nobody

clientmethod: none

client pass {

from: 0.0.0.0/0 to: 0.0.0.0/0

log: error

}

```

Key Configuration Options:

1. internal: This specifies the IP address and port the SOCKS5 proxy will listen on. `0.0.0.0` means it will listen on all available network interfaces. The default port for SOCKS5 is `1080`, but you can change it as needed.

2. external: This specifies the network interface Dante should use for outgoing connections (usually your primary network interface like `eth0`).

3. method: This defines the authentication method. The `username none` option means no authentication is required, but for added security, you can enable username/password authentication.

4. clientmethod: This dictates which IP addresses are allowed to connect to the proxy. By default, `none` means any client can connect, but you may restrict this to certain IPs for extra security.

5. user.privileged: This is the user that the SOCKS5 proxy will run as. Typically, this should be the root user for setup and configuration.

6. user.unprivileged: This is the user the SOCKS5 proxy will run as when handling client requests. In many setups, this is set to `nobody` to limit security risks.

After making the necessary changes, save and exit the file.

Step 3: Starting the Dante Service

Once the configuration file is set up, you can start the Dante server. On most Linux systems, the following commands will start the service:

```bash

sudo systemctl start danted

```

To ensure the service starts automatically on boot, use the following command:

```bash

sudo systemctl enable danted

```

Verify the service is running:

```bash

sudo systemctl status danted

```

If everything is set up correctly, you should see that the Dante server is active and listening on the specified port.

Step 4: Configuring the Firewall

Now that the socks5 proxy server is up and running, you need to ensure that your firewall allows traffic on the port you've chosen (default is `1080`). If you're using `ufw` (Uncomplicated Firewall) on Ubuntu/Debian, you can allow traffic with the following command:

```bash

sudo ufw allow 1080/tcp

```

If you're using `firewalld` on CentOS/Fedora, run:

```bash

sudo firewall-cmd --zone=public --add-port=1080/tcp --permanent

sudo firewall-cmd --reload

```

This ensures that external devices can connect to your proxy server on the specified port.

Step 5: Testing the SOCKS5 Proxy

To test your SOCKS5 proxy, you can use a tool like `curl` or configure a web browser to connect through the proxy.

For testing with `curl`, you can run the following command:

```bash

curl --proxy socks5://your-server-ip:1080 http://example.com

```

If everything is working correctly, this should route your connection through the SOCKS5 proxy and fetch the page, which you can verify by checking the IP address from which the request originates.

Alternatively, you can configure your browser or application to use the SOCKS5 proxy by specifying the IP address of your server and port `1080`. The exact steps will depend on the application you're using.

Step 6: Securing the SOCKS5 Proxy

While setting up the proxy, it’s essential to focus on security. Here are a few steps to improve the security of your SOCKS5 proxy:

1. Enable authentication: Configure username and password authentication in the Dante configuration file.

2. Restrict access: Only allow specific IP addresses to connect by modifying the `client pass` rule.

3. Monitor logs: Regularly check the server logs for any unusual activity or unauthorized access attempts.

Conclusion

Setting up a SOCKS5 proxy on a Linux system is a relatively simple process that involves installing the appropriate software, configuring the server, and ensuring proper firewall and security settings. By following this guide, you can create a secure and anonymous browsing experience while also enabling access to restricted content or applications. Always ensure that your proxy is protected with authentication and that only trusted users have access to it, to maintain the integrity of your network security.