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 private proxy on Linux system?

How to configure Socks5 private proxy on Linux system?

PYPROXY PYPROXY · Apr 11, 2025

Setting up a private socks5 proxy on a Linux system can greatly enhance privacy, security, and control over your internet traffic. SOCKS5 is a versatile and widely-used proxy protocol, supporting various types of network traffic and offering higher performance compared to other proxies. This guide will explain the steps to configure a socks5 proxy server on your Linux machine, detailing every part of the process and how you can optimize your system for better security and anonymity. Whether you're a network administrator or an individual seeking enhanced privacy, configuring a private SOCKS5 proxy is a useful and powerful tool for controlling your internet connections.

Understanding SOCKS5 and Its Benefits

Before diving into the configuration steps, it's important to understand the benefits of using a SOCKS5 proxy. SOCKS5, unlike traditional HTTP proxies, handles all kinds of traffic (including TCP and UDP). This makes it an ideal choice for applications that need to handle a variety of protocols and high-bandwidth requirements, such as peer-to-peer file sharing, secure browsing, and online gaming. The protocol works at the transport layer, providing flexibility and efficiency in routing network requests.

Some of the key benefits of SOCKS5 include:

1. Higher Flexibility: SOCKS5 supports all types of traffic, including DNS requests and UDP packets.

2. Better Security: It can handle authentication methods that provide better security, such as username/password authentication.

3. Improved Performance: Since it doesn’t modify your traffic, SOCKS5 tends to have lower latency and faster speeds compared to other proxy types like HTTP proxies.

With this understanding, let's move forward with setting up a SOCKS5 proxy on Linux.

Step 1: Install the SOCKS5 Proxy Software

The first step in setting up a SOCKS5 proxy is installing the software that will serve as your proxy server. There are several tools available to help you set up a SOCKS5 server on Linux, with Dante and Shadowsocks being two of the most common options. In this guide, we will focus on Dante, an open-source SOCKS server that is reliable and widely used for creating sock s5 proxies.

To install Dante on a Linux system, you can follow these commands:

1. Update the package list:

```

sudo apt update

```

2. Install the Dante server:

```

sudo apt install dante-server

```

Dante provides a robust configuration for setting up a private SOCKS5 proxy. After installation, you can move on to configuring the proxy.

Step 2: Configure the SOCKS5 Proxy Server

Once Dante is installed, it’s time to configure the SOCKS5 server. Dante uses a configuration file located at `/etc/danted.conf`. This file will contain all the necessary settings for your proxy server, including network interfaces, authentication methods, and access control lists.

1. Edit the configuration file:

```

sudo nano /etc/danted.conf

```

2. Basic configuration:

A simple SOCKS5 server configuration will look like this:

```

logoutput: /var/log/dante.log

internal: eth0 port = 1080

external: eth0

method: username

user.notprivileged: nobody

clientmethod: none

socksmethod: none

userlibwrap: no

```

- `internal: eth0 port = 1080`: This sets the internal interface (`eth0`) and the port (`1080`) where the proxy will listen for incoming connections.

- `external: eth0`: Specifies the external interface used for outgoing connections.

- `method: username`: This defines the authentication method, where users must authenticate with a username and password.

- `user.notprivileged: nobody`: This ensures that the SOCKS5 server runs with low privileges to avoid security risks.

3. Save and exit:

After editing the configuration, save the file and exit the editor. You can save in nano by pressing `CTRL+X`, then `Y`, and finally `Enter`.

Step 3: Configure Firewall and Access Control

Once the basic configuration is set, you need to ensure that your server’s firewall allows access to the SOCKS5 proxy and that only authorized users can connect to it.

1. Configure the firewall:

Use `ufw` or `iptables` to open port 1080 (or whichever port you have configured the proxy to use). To allow access on port 1080 with `ufw`, run:

```

sudo ufw allow 1080/tcp

```

2. Set up access control:

You can define specific client IPs or ranges that are allowed to connect to your SOCKS5 server. This is useful for preventing unauthorized access. Add access control rules to the configuration file by specifying which IPs are allowed to connect to the proxy.

PYPROXY of adding access control to the `danted.conf` file:

```

client pass {

from: 192.168.1.0/24 to: 0.0.0.0/0

log: connect disconnect error

}

```

This will allow clients from the `192.168.1.0/24` network to connect, while others are denied.

Step 4: Start the SOCKS5 Server

After configuring everything, you can now start the SOCKS5 server.

1. Start the Dante service:

```

sudo systemctl start danted

```

2. Enable it to start on boot:

```

sudo systemctl enable danted

```

3. Check the status:

To make sure that the server is running properly, you can check the status of the Dante service:

```

sudo systemctl status danted

```

If everything is set up correctly, you should see the service is active and running.

Step 5: Testing the SOCKS5 Proxy Server

To ensure your SOCKS5 server is working as expected, you can test the connection using a browser or terminal.

1. Test with a web browser:

Configure your browser to use a SOCKS5 proxy by specifying the IP address and port (1080) of your Linux machine. For pyproxy, in Firefox, you can go to `Preferences > Network Settings > Manual proxy configuration`, select SOCKS5, and enter the server’s IP address and port.

2. Test with `curl`:

You can also use `curl` to test the SOCKS5 proxy:

```

curl --proxy socks5h://:1080 http://pyproxy.com

```

If the connection is successful, you’ll see the response from the website, indicating that the SOCKS5 proxy is functioning correctly.

Step 6: Optional – Automating the Server Setup

For better management, you may want to automate the process of starting and stopping your SOCKS5 proxy server. Creating a script that handles starting the server on boot and restarting it if necessary is a good practice. You can place this script in `/etc/init.d/` or create a systemd service to manage it.

Additionally, you may want to set up logging and monitoring to track usage and ensure the system is performing optimally.

Setting up a private SOCKS5 proxy on a Linux machine is a valuable skill for enhancing security, privacy, and network control. By following the steps outlined in this guide, you can have your SOCKS5 server up and running, offering a flexible and secure method for routing network traffic. Whether you're using it for browsing, secure communication, or controlling access to your network, a well-configured SOCKS5 proxy can offer a significant boost to your online security and privacy.

Related Posts