Ubuntu20.4使用Dante建立socks5代理
Ubuntu20.4使用Dante建立socks5代理
最近因为项目需要搭建代理访问服务,看了很多文章,搭好后都有问题,最常见的问题就是安装后无法启动danted服务,后边看了一篇国外的文章,搭建成功,过程如下。
一、安装Dante
sudo apt update
sudo apt install dante-server
输入如下命令查看Dante服务状态
systemctl status danted.service
可以看到输出了 Active: failed 和一堆告警
先不管,接下来配置dante
二、配置Dante
Dante的配置文件为/etc/danted.conf ,良好习惯,先备份原配置文件
cp /etc/danted.conf /etc/danted.conf.bk
然后将/etc/danted.conf 中的内容全部替换为以下内容(如何替换就不赘述了,vi/vim编辑等等都行)
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: eth0
# 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
}
配置文件中配置了socks服务端口为1080,在防火墙放行1080端口
sudo ufw allow 1080
如果是VPS,记得在安全组中放行1080端口
三、配置登录用户名和密码
配置登录用户名
sudo useradd -r -s /bin/false username #写个自己喜欢的用户名
为用户名配置密码
sudo passwd username #注意这里是为新加的用户设置密码,根据提示设置密码和确认密码,即可完成
四、配置限制客户端IP(非必须,可跳过)
如果不需要限制客户端IP范围,跳过这一步即可,如果需要限制客户端IP范围,可以在/etc/danted.conf文件中修改以下内容
client pass {
from:ip_address/0 to: 0.0.0.0/0
}
ip_address可以是单个IP或者IP地址段,如果需要添加多个IP或IP段,继续添加以上代码,更换IP或IP段即可
五、启动danted服务
执行以下命令启动danted服务
sudo systemctl restart danted.service
查看服务状态
systemctl status danted.service
可以看到服务已经启动了active(running)
查看端口监听情况
netstat -anp | grep tcp
可以看到danted正常监听1080端口
六、代理连接测试
(1)使用curl测试(Linux和windows均需自己安装,这一步非必需)
curl -v -x socks5://username:password@server_ip:1080 http://www.baidu.com/
username和password均是刚才设置的
回复以下信息说明搭建成功了
(2)使用火狐浏览器进行socks5代理访问网站
首先在火狐浏览器扩展中下载一个代理管理器Foxyproxy
然后【选项】-【添加代理】:
【标题】:自己随便写
【代理类型】:socks5
【代理IP地址或DNS名称】:你的dante服务器IP
【端口】:1080
【用户名】:配置dante时设置的用户名
【密码】:配置dante时设置的密码
最后保存,然后回到浏览器界面,点击选择刚才添加的代理,就可以使用代理服务器访问应用了
很多文章写得很复杂,而且最常见的问题是安装后无法启动danted服务,我是参考了这个链接:
How to Set Up Dante Proxy for Private Connections on Ubuntu 20.04
更多推荐
所有评论(0)