常見的代理協議有 http、https、socks4/5 這三種,http協議的代理搭建方案最簡單,但是http代理無法訪問https網站,https代理無法實作呼叫遠端dns,所以我個人推薦使用Scoks5協議做代理,本文用于記錄在Ubuntu系統中搭建Socks5代理的詳細步驟,采用dante-server作為服務端,
首先更新服務器安裝源
sudo apt-get update
執行安裝命令
sudo apt-get install dante-server
添加一個用戶用于進行連接代理時的身份驗證
sudo useradd zhangxiaodong
sudo passwd zhangxiaodong
由于我們只想使用這個用戶用作Socks的代理登陸驗證,所以禁止這個用戶的系統登陸權限
sudo vim /etc/passwd
將zhangxiaodong的shell改成 /bin/false,如下圖

sudo vim /etc/danted.conf
清空原來的內容輸入以下內容
我這邊的服務器網卡IP為 172.16.50.1,并采用 1080 作為代理埠則配置如下
logoutput: stderr
internal: 172.16.50.1 port = 1080
external: 172.16.50.1
#驗證賬戶:username 不驗證賬戶:none
method: username
user.privileged: root
user.notprivileged: nobody
user.libwrap: nobody
compatibility: sameport
compatibility: reuseaddr
extension: bind
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect disconnect error
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bind
log: connect disconnect error
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bindreply udpreply
log: connect error
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0 port 1-65535
protocol: tcp udp
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0 port 1-65535
command: udpassociate
}
保存退出即可,然后執行啟動
sudo /etc/init.d/danted start
查看服務運行狀態
sudo netstat -anp | grep 1080
至此關于 基于 Ubuntu 服務器配置原生的 Socks5 網關代理服務器 就講解完了,有任何不明白的,可以在文章下面評論或者私信我,歡迎大家積極的討論交流,有興趣的朋友可以關注我目前在維護的一個 .NET 基礎框架專案,專案地址如下
https://github.com/berkerdong/NetEngine.git
https://gitee.com/berkerdong/NetEngine.git
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/543570.html
標籤:其他
