Setting Up a SOCKS5 Proxy with Authentication on Ubuntu 22.04.4
Setting up a SOCKS5 proxy with authentication on Ubuntu 22.04.4 involves several steps, including installing the necessary software, configuring the proxy, and setting up authentication. Here’s a step-by-step guide:
Step 1: Update Your System
First, ensure your system is up to date by running:
# sudo apt update && sudo apt upgrade -y
Step 2: Install dante-server
Dante is a popular SOCKS proxy server. Install it using the following command:
# sudo apt install dante-server -y
Step 3: Configure dante-server
Create and edit the Dante server configuration file:
# sudo nano /etc/danted.conf
Replace the contents of the file with the following configuration:
logoutput: syslog
user.privileged: root
user.unprivileged: nobody
# The listening network interface or address.
internal: 0.0.0.0 port=1080
# The proxying network interface or address.
external: eno1
# socks-rules determine what is proxied through the external interface.
socksmethod: username
# client-rules determine who can connect to the internal interface.
clientmethod: none
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
- internal: Interface to listen on and the port number (e.g.,
eth0
and1080
). - external: Interface to use for outgoing traffic (e.g.,
eth0
).
Adjust eth0
to your network interface name if different.
Step 4: Set Up User Authentication
Add users for proxy authentication. Use the following command to create a user (replace username
with your desired username):
# sudo adduser username
Follow the prompts to set a password.
Step 5: Enable and Start the dante-server
Enable and start the Dante service using the following commands:
sudo systemctl enable danted
sudo systemctl start danted
Step 6: Verify the Proxy Server
To ensure the proxy server is running, use the following command:
sudo systemctl status danted
You should see output indicating that the service is active and running.
Step 7: Configure Firewall (Optional)
If you have a firewall enabled, allow traffic on the SOCKS5 port (e.g., 1080):
sudo ufw allow 1080/tcp
sudo ufw allow 1080/udp
Testing the SOCKS5 Proxy
To test the proxy server, you can use tools like curl
. Replace username
and password
with the credentials you created:
curl -x socks5://username:password@your_server_ip:1080 http://ipinfo.io
You should see output with your server’s IP address.
Additional Security Measures
- Firewall Rules: Restrict access to the proxy server to specific IP addresses if needed.
- Logging: Configure logging to monitor usage and detect any potential issues.
Conclusion
Following these steps will set up a SOCKS5 proxy with authentication on Ubuntu 22.04.4. Ensure to keep the system and dante-server
updated for security and performance improvements.