Dante是一个免费的Socks代理服务器,当然,其实开发它的公司,是通过销售扩展Modules以及服务来赚钱的。如果只是需要代理,就不需要那些额外的Modules了(安全/流控之类会做在防火墙上,专业的设备做专业的事)
Dante官方网站上只给了源码和编译好的二进制文件,二进制文件有适配RHEL7的,也就可以用在centOS7上,但是,这些文件下载或者编译后,还需要自己去配置环境变量和启动配置,卸载起来也不容易(编译安装可以通过make uninstall
来卸载),总之,不是很方便
centOS7的标准库中不包含Dante Socks,很蛋疼,我们需要用到GhettoForge库
通过扩展库安装的Dante的版本是1.4.1,虽然不是最新版,但也够用了(最新版也就是1.4.2)
通过yum安装时,会同时安装server和client端
Yum 安装
添加库
1 |
<code>rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm</code> |
安装这个库之后,仍然会发现找不到……
1 2 3 4 5 6 7 8 9 |
# yum search dante-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.aliyun.com * extras: mirrors.163.com * updates: mirrors.163.com Warning: No matches found for: dante-server No matches found |
因为dante-server默认在gf-plus库中,需要手动启用
1 2 3 4 5 6 7 8 9 |
# yum --enablerepo=gf-plus search dante-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.aliyun.com * extras: mirrors.163.com * updates: mirrors.163.com ============================================== N/S matched: dante-server =============================================== dante-server.x86_64 : A Free Socks v4/v5 Server Implementation |
搜索对应有安装包,开始安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# yum --enablerepo=gf-plus install dante-server -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.aliyun.com * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package dante-server.x86_64 0:1.4.1-176.9 will be installed --> Processing Dependency: dante for package: dante-server-1.4.1-176.9.x86_64 --> Running transaction check ---> Package dante.x86_64 0:1.4.1-176.9 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: dante-server x86_64 1.4.1-176.9 gf-plus 331 k Installing for dependencies: dante x86_64 1.4.1-176.9 gf-plus 480 k Transaction Summary ======================================================================================================================== Install 1 Package (+1 Dependent package) Total download size: 811 k Installed size: 2.4 M Downloading packages: warning: /var/cache/yum/x86_64/7/gf-plus/packages/dante-server-1.4.1-176.9.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID da8b7718: NOKEY Public key for dante-server-1.4.1-176.9.x86_64.rpm is not installed (1/2): dante-server-1.4.1-176.9.x86_64.rpm | 331 kB 00:00:12 (2/2): dante-1.4.1-176.9.x86_64.rpm | 480 kB 00:00:12 ------------------------------------------------------------------------------------------------------------------------ Total 65 kB/s | 811 kB 00:00:12 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7 Importing GPG key 0xDA8B7718: Userid : "Ghettoforge (el7) <gf@ghettoforge.org>" Fingerprint: b43e a892 86f4 b6fd ff83 fed1 d005 ae31 da8b 7718 Package : gf-release-7-10.gf.el7.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : dante-1.4.1-176.9.x86_64 1/2 Installing : dante-server-1.4.1-176.9.x86_64 2/2 Verifying : dante-server-1.4.1-176.9.x86_64 1/2 Verifying : dante-1.4.1-176.9.x86_64 2/2 Installed: dante-server.x86_64 0:1.4.1-176.9 Dependency Installed: dante.x86_64 0:1.4.1-176.9 Complete! |
Dante安装后配置
添加一个用户,专用于Dante Socks使用;
1 |
adduser --no-create-home --shell /usr/sbin/nologin dante-socks |
创建下面这个文件夹,通过上述yum源安装的Dante Socks,不知为何不会创建这个目录,但启动的配置文件中,是需要这个目录的,Dante会在目录下创建一个sockd.pid
的文件
1 |
# mkdir /var/run/sockd |
启动服务配置文件在这里
1 |
# vi /usr/lib/systemd/system/sockd.service |
Dante 配置文件说明
通过yum安装的Dante Socks会有一个默认的sockd.conf
文件,存在/etc
目录下
如果你熟悉Dante的配置文件语义,你就不需要这个文件,以防万一,还是先重命名一下
1 |
# mv /etc/sockd.conf /etc/sockd.conf.default |
然后我们创建自己的conf文件
1 |
# vi /etc/sockd.conf |
配置示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
logoutput: stderr internal: eth0 port = 1080 external: eth0 socksmethod: none user.privileged: root user.unprivileged: nobody client pass { from: 0.0.0.0/0 to: 0.0.0.0/0 log: connect disconnect } pass { from: 0.0.0.0/0 to: 0.0.0.0/0 protocol: tcp udp log: connect disconnect } |
Dante 配置文件的规则和语义参考这里
https://www.inet.no/dante/doc/1.4.x/config/server.html
启动服务
最后通过 systemctl 命令启动服务即可
1 2 3 |
systemctl enable sockd.service systemctl start sockd.service systemctl status sockd.service |