Linux 编译安装 Dante SOCKS 代理服务器

Linux 编译安装 Dante SOCKS 代理服务器

本文使用 Dante 作为服务端,点击进入官网

1. 安装代理服务

# CentOS
yum -y install gcc openssl-devel pcre-devel zlib-devel libtool c++ pam-devel pam
# Debian
apt-get install build-essential
# Get source code
wget http://www.inet.no/dante/files/dante-1.4.2.tar.gz
tar xvzf dante-1.4.2.tar.gz
cd dante-1.*
./configure && make && make install
useradd  -s /sbin/nologin sockd
passwd sockd

编辑配置文件,/etc/sockd.conf写入如下代码:

#logging
#errorlog: /var/log/sockd.errlog
logoutput: /var/log/sockd.log
#debug: 2

#server address specification
internal: eth0 port = 1080
external: eth0

#server identities (not needed on solaris)
user.privileged: root
#user.notprivileged: socks
#user.libwrap: libwrap

#reverse dns lookup
#srchost: nodnsmismatch

#authentication methods
socksmethod: username none

##
## SOCKS client access rules
##
#rule processing stops at the first match, no match results in blocking

#block access to socks server from 192.0.2.22 (exception for pass rule below)
# client block {
#       #block connections from 192.0.2.22/32
#       from: 192.0.2.22/24 to: 0.0.0.0/0
#       log: error # connect disconnect
# }

#allow connections from local network (192.0.2.0/24)
client pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
    log: error # connect disconnect
}
pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0 port gt 1023
    command: bind
    log: connect disconnect
}
pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
    command: connect udpassociate
    log: connect disconnect
}
block {
        from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect error
}

2. 启动服务

使用以下#1命令即可启动sockd,日志存在/etc/sockd.conf

/usr/local/sbin/sockd -f /etc/sockd.conf &

3. 查看连接日志

tail -f /var/log/sockd.log

4. 检查进程启动

执行

netstat -lntp

如果看到你指定的(111.111.111.111为示例IP)端口被 dante 进程监听即表示成功启动。

root@domain:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      795/sshd
tcp        0      0 111.111.111.111:1080     0.0.0.0:*               LISTEN      907/sockd  

注意:设置自启动把#1命令,添加到/etc/rc.local即可。

标签:none

添加新评论