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 configure SOCKS5 proxy on Linux server?

How to configure SOCKS5 proxy on Linux server?

Author:PYPROXY
2025-02-14

Setting up a socks5 proxy on a Linux server is an essential task for users seeking privacy and security online. SOCKS5, being a versatile and secure proxy protocol, allows for a wide range of applications, including bypassing firewalls and accessing region-restricted content. Unlike other types of proxies, SOCKS5 does not modify the traffic, thus providing better performance and flexibility. It supports various protocols like HTTP, HTTPS, FTP, and more. This guide will walk you through the process of configuring a SOCKS5 proxy on your Linux server, ensuring your system is protected while browsing the web or handling other network operations securely.

Understanding SOCKS5 Proxy

Before diving into the configuration process, it is crucial to understand what SOCKS5 proxy is and why it is often chosen over other types of proxies.

SOCKS (Socket Secure) is a protocol that routes traffic between a client and a server through a proxy server. SOCKS5, the latest version, is highly regarded due to its enhanced security features, support for authentication, and the ability to handle various types of network traffic, including UDP and TCP.

Unlike traditional proxies, SOCKS5 does not alter or examine the content of the traffic passing through it. This results in better performance and minimal interference, especially when dealing with encrypted data or streaming services. Moreover, SOCKS5 is particularly useful for accessing geo-restricted content, providing anonymity, and bypassing network censorship.

Prerequisites for Setting Up a SOCKS5 Proxy on Linux

Before you begin configuring the SOCKS5 proxy, ensure the following prerequisites are in place:

1. Linux Server: The first requirement is a Linux server. This server could be running any popular Linux distribution, such as Ubuntu, CentOS, or Debian.

2. Root or Sudo Access: You will need root access or sudo privileges to install and configure the necessary software.

3. Internet Connection: Ensure that the server has an active and stable internet connection to ensure uninterrupted proxy service.

Step-by-Step Guide to Configure SOCKS5 Proxy on Linux

Now, let’s break down the process into manageable steps for setting up a SOCKS5 proxy on a Linux server.

Step 1: Install Required Software

To begin, you will need to install the socks5 proxy server software on your Linux system. The most popular choice for this task is Dante or Shadowsocks, but for this guide, we will focus on using Dante.

1. Update the Package List: Start by updating your package manager’s list to ensure you get the latest version of the software.

```bash

sudo apt update

```

2. Install Dante Server: Dante is a robust and reliable proxy server that supports SOCKS5. Install it by running:

```bash

sudo apt install dante-server

```

3. Check Installation: Once installed, you can check if the server is correctly installed by verifying its version:

```bash

socksd -v

```

Step 2: Configure Dante for SOCKS5 Proxy

Once the software is installed, it’s time to configure the SOCKS5 proxy. Follow these steps:

1. Edit the Configuration File: The primary configuration file for Dante is located at `/etc/danted.conf`. Open this file with your preferred text editor:

```bash

sudo nano /etc/danted.conf

```

2. Basic Configuration: Add the following lines to configure the SOCKS5 proxy. Ensure that the configuration reflects your server's needs:

```

logoutput: /var/log/dante.log

internal: eth0 port = 1080

external: eth0

method: username none

user.notprivileged: nobody

clientmethod: none

socksmethod: username

```

Explanation of the configuration:

- `internal`: Specifies the network interface and port the SOCKS5 proxy will listen on (in this case, eth0 and port 1080).

- `external`: Specifies the external network interface for the proxy to connect to.

- `method`: Defines the authentication methods allowed for connecting to the SOCKS5 server. In this case, "none" and "username."

- `user.notprivileged`: Sets the user under which the proxy service will run (here, it is "nobody").

3. Save and Exit: After completing the configuration, save the changes and exit the editor.

Step 3: Start and Enable the Dante Service

Once the configuration is complete, you can start the Dante service. Run the following commands:

1. Start the Dante Service:

```bash

sudo systemctl start dante-server

```

2. Enable the Service at Boot:

```bash

sudo systemctl enable dante-server

```

3. Check the Status: Ensure the service is running without any issues by checking its status:

```bash

sudo systemctl status dante-server

```

Step 4: Configuring Firewall Rules

To ensure that the SOCKS5 proxy is accessible, you need to allow traffic on the designated port (port 1080 in this case). This can be done by modifying the firewall rules.

1. Allow Port 1080: If you are using UFW (Uncomplicated Firewall), run:

```bash

sudo ufw allow 1080

```

2. Reload the Firewall: After updating the firewall rules, reload the firewall for the changes to take effect:

```bash

sudo ufw reload

```

3. Verify the Rules: Check the status of your firewall to verify that the changes have been applied:

```bash

sudo ufw status

```

Step 5: Testing the SOCKS5 Proxy

To test the proxy setup, you can use tools like `curl` or `proxychains`. For instance, you can use `curl` to check the connection through the SOCKS5 proxy.

1. Test with Curl:

```bash

curl --socks5 localhost:1080 http://www.google.com

```

2. Verify the Output: If everything is configured correctly, you should be able to browse the web using the SOCKS5 proxy without any issues.

Step 6: Setting Up Authentication for the SOCKS5 Proxy

While the basic configuration above does not require authentication, it’s often a good practice to implement authentication for additional security. You can configure username and password-based authentication to restrict access.

1. Create a User: Add a user specifically for accessing the SOCKS5 proxy:

```bash

sudo adduser proxyuser

```

2. Update Configuration for Authentication: Edit the `danted.conf` file and modify the `socksmethod` line to:

```

socksmethod: username

```

3. Restart the Dante Service: After making changes to the configuration, restart the service to apply the changes:

```bash

sudo systemctl restart dante-server

```

Conclusion

Configuring a SOCKS5 proxy on a Linux server is a straightforward process that enhances security and anonymity for users. By following the steps outlined above, you can easily set up a SOCKS5 proxy, control access with authentication, and ensure your traffic remains secure. SOCKS5 is a versatile solution for bypassing internet restrictions, enhancing privacy, and securing online activities. Whether for personal use or as part of a larger network management system, the SOCKS5 proxy is a valuable tool in the modern web landscape.