How to setup sock5 proxy on ubuntu
Overview
setup socks5.sh
1
2#!/bin/bash
3
4echo -e "Please enter the username for the socks5 proxy:"
5read username
6echo -e "Please enter the password for the socks5 proxy:"
7read -s password
8
9# Update repositories
10sudo apt update -y
11
12# Install dante-server
13sudo apt install dante-server -y
14
15# Create the configuration file
16sudo bash -c 'cat <<EOF > /etc/danted.conf
17logoutput: /var/log/danted.log
18internal: 0.0.0.0 port = 1080
19external: eth0
20method: username none
21user.privileged: root
22user.notprivileged: nobody
23client pass {
24 from: 0.0.0.0/0 to: 0.0.0.0/0
25 log: connect disconnect error
26}
27socks pass {
28 from: 0.0.0.0/0 to: 0.0.0.0/0
29 log: connect disconnect error
30}
31EOF'
32
33# Add user with password
34sudo useradd --shell /usr/sbin/nologin $username
35echo "$username:$password" | sudo chpasswd
36
37# Check if UFW is active and open port 1080 if needed
38if sudo ufw status | grep -q "Status: active"; then
39 sudo ufw allow 1080/tcp
40fi
41
42# Check if iptables is active and open port 1080 if needed
43if sudo iptables -L | grep -q "ACCEPT tcp -- anywhere anywhere tcp dpt:1080"; then
44 echo "Port 1080 is already open in iptables."
45else
46 sudo iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
47fi
48
49# Restart dante-server
50sudo systemctl restart danted
51
52# Enable dante-server to start at boot
53sudo systemctl enable danted
open port 1080 on firewall
run sock5.sh
1sudo bash socks5.sh
Testing the Proxy
1
2apt-get install nc
3
4nc -zv proxyServerIP 1080
5
6curl -x socks5://username:password@proxyServerIP:1080 https://ifconfig.me
if the IP is the proxyServerIP ,then it works