This page looks best with JavaScript enabled

Providing SOCKS5 Forwarding with Dante

 ·  ☕ 2 min read

Because the servers in the data center are bound to a small bandwidth, this post is mainly about using Dante to provide SOCKS5 forwarding, using some high-bandwidth servers for traffic forwarding to speed up dependency package downloads.

1. Find a High-Bandwidth Server

  • Install speedtest-cli
1
pip3 install  speedtest-cli
  • List peer test servers
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
speedtest-cli --secure --list

Retrieving speedtest.net configuration...
 5396) China Telecom JiangSu 5G (Suzhou, China) [747.08 km]
16204) JSQY - Suzhou (Suzhou, China) [747.08 km]
 4575) China Mobile Group Sichuan (Chengdu, China) [1012.06 km]
17634) China Mobile (Fujian, China) [1102.09 km]
67564) MOACK Data Center (Yongin-si, South Korea) [1240.80 km]
62580) Skymedia (Ulaanbaatar, Mongolia) [1566.70 km]
 3805) Alyans Telekom (Vladivostok, Russia) [1822.03 km]
27732) Telenet-Chita (Chita, Russia) [1921.20 km]
36254) EDINOS (Ulan-Ude, Russia) [1959.23 km]
37436) RLINE1 (Svobodny, Russia) [2177.33 km]

The first column is the ID of the test server we need.

  • Test speed

Domestic

1
speedtest-cli --secure --server 5396

Overseas

1
speedtest-cli --secure --server 37436

2. Deploy the Dante Server

  • Install dante
1
apt install dante-server -y
  • Generate the configuration file
1
ip route | grep default | awk '{print $5}'

Find the name of the default NIC; here it is bond0.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
cat > /etc/danted.conf <<EOF
logoutput: syslog
internal: 0.0.0.0 port = 1080
external: bond0

method: username none
user.privileged: root
user.unprivileged: nobody

client pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect
}

socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect
}
EOF
  • Start the service
1
2
systemctl restart danted
systemctl enable danted

3. Configure the Client

  • Configure the proxy
1
export ALL_PROXY="socks5://x.x.x.x:1080"
  • Test the proxy
1
curl ifconfig.me

At this point it should output the IP address of the forwarder above.

  • Clean up the proxy
1
unset ALL_PROXY

4. Using a Proxy with apt-get

  • Configure apt-get to use a proxy
1
vim /etc/apt/apt.conf

Add the following content

1
2
Acquire::http::proxy "socks5h://x.x.x.x:1080";
Acquire::https::proxy "socks5h://x.x.x.x:1080";
  • Update apt-get
1
apt-get update

But this approach cannot update apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05; you need to download and import it manually.

5. Installing proxychains

  • Install proxychains
1
apt install proxychains -y
  • Configure proxychains
1
vim /etc/proxychains.conf

Add the following content

1
socks5 x.x.x.x 1080
  • Use proxychains
1
proxychains apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05

When using a proxy, you only need to prefix the command with proxychains.


微信公众号
WRITTEN BY
微信公众号