Установка Socks 5 сервера

BlablaОбновляем ось
apt-get update && apt-get upgrade
Ставим пакеты для компиляции исходников
apt-get install build-essential

ставим mc (оболочка типа Far-менеджер, для его запуска если необходимо
набираем комманду mc)
apt-get install mc

качаем свежий прокси
wget http://www.inet.no/dante/files/dante-1.4.0-pre1.tar.gz
распаковываем
tar zxvf dante-1.4.0-pre1.tar.gz
cd dante-1.4.0-pre1


Сборка и установка
./configure
make
make install


Создаем юзера
cat /dev/null  >> /etc/shells
useradd -s /dev/null Blablabauser
passwd Blablabauser

забиваем пароль

готовим файл конфига
mcedit /etc/sockd.conf

Вставляем в файл конфига
####################################
# $Id: sockd.conf,v 1.43 2005/12/26 16:35:26 michaels Exp $

# A sample danted.conf

# The configfile is divided into three parts;.
#    1) serversettings
#    2) rules
#    3) routes

# The recommended order is:
#   Serversettings:
#               logoutput
#               internal
#               external
#               method
#               clientmethod
#               users
#               compatibility
#               extension
#               connecttimeout
#               iotimeout
#          srchost

#  Rules:
#     client block/pass
#          from to
#          libwrap
#          log

#     block/pass
#          from to
#          method
#          command
#          libwrap
#          log
#          protocol
#          proxyprotocol

#  Routes:.

# the server will log both via syslog, to stdout and to /var/log/lotsoflogs
#logoutput: syslog stdout /var/log/lotsoflogs
logoutput: /var/log/socks.log

# The server will bind to the address 10.1.1.1, port 1080 and will only
# accept connections going to that address.
#internal: 10.1.1.1 port = 1080
# Alternatively, the interface name can be used instead of the address.

internal: venet0:0 port = 29893
internal: venet0:17 port = 29893
internal: venet0:18 port = 29893
internal: venet0:19 port = 29893
internal: venet0:20 port = 29893
internal: venet0:21 port = 29893
internal: venet0:22 port = 29893
internal: venet0:23 port = 29893
internal: venet0:24 port = 29893
internal: venet0:25 port = 29893
internal: venet0:26 port = 29893
internal: venet0:27 port = 29893
internal: venet0:28 port = 29893
internal: venet0:29 port = 29893
internal: venet0:30 port = 29893
internal: venet0:31 port = 29893

# all outgoing connections from the server will use the IP address
# 195.168.1.1
external.rotation: same-same

external: venet0:0
external: venet0:17
external: venet0:18
external: venet0:19
external: venet0:20
external: venet0:21
external: venet0:22
external: venet0:23
external: venet0:24
external: venet0:25
external: venet0:26
external: venet0:27
external: venet0:28
external: venet0:29
external: venet0:30
external: venet0:31

# list over acceptable methods, order of preference.
# A method not set here will never be selected.

# If the method field is not set in a rule, the global
# method is filled in for that rule.

method: username none

user.privileged: root
user.unprivileged: nobody
#user.libwrap: nobody

compatibility: sameport
extension: bind

timeout.negotiate: 30   # on a lan, this should be enough.
timeout.io: 0

client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
}

# Блокируем обращения к localhost
client block {
from: 0.0.0.0/0 to: 127.0.0.0/8
log: connect error
}

# Разрешаем работать с прокси с верным именем и паролем.
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
method: username
}
# Блокируем всех остальных
block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}

####################################

Создаем файл автозапуска
mcedit /etc/init.d/sockd
Вставляем в файл
####################################
#! /bin/sh
### BEGIN INIT INFO
# Provides:          danted
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SOCKS (v4 and v5) proxy daemon (danted)
### END INIT INFO

# dante SOCKS server init.d file. Based on /etc/init.d/skeleton:
# Version:<—->@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/sockd
NAME=sockd
DESC=”Dante SOCKS daemon”
PIDFILE=/var/run/$NAME.pid
CONFFILE=/etc/$NAME.conf

test -f $DAEMON || exit 0

set -e

# This function makes sure that the Dante server can write to the pid-file.
touch_pidfile ()

if [ -r $CONFFILE ]; then
uid=”`sed -n -e ‘s/[[:space:]]//g’ -e ‘s/#.*//’ -e ‘/^user\.privileged/{s/[^:]*://p;q;}’ $CONFFILE`”
if [ -n “$uid” ]; then
touch $PIDFILE
chown $uid $PIDFILE
fi
fi

case “$1” in
start)
if ! egrep -cve ‘^ *(#|$)’ \
-e ‘^(logoutput|user\.((not)?privileged|libwrap)):’ \
$CONFFILE > /dev/null
then
echo “Not starting $DESC: not configured.”
exit 0
fi
echo -n “Starting $DESC: ”
touch_pidfile
start-stop-daemon –start –quiet –oknodo –pidfile $PIDFILE \
–exec $DAEMON — -D
echo “$NAME.”
;;
stop)
echo -n “Stopping $DESC: ”
start-stop-daemon –stop –quiet –oknodo –pidfile $PIDFILE \
–exec $DAEMON
echo “$NAME.”
;;
reload|force-reload)
#
#     If the daemon can reload its config files on the fly
#     for example by sending it SIGHUP, do it here.
#
#     If the daemon responds to changes in its config file
#     directly anyway, make this a do-nothing entry.
#
echo “Reloading $DESC configuration files.”
start-stop-daemon –stop –signal 1 –quiet –pidfile \
$PIDFILE –exec $DAEMON — -D
;;
restart)
#
#     If the “reload” option is implemented, move the “force-reload”
#     option to the “reload” entry above. If not, “force-reload” is
#     just the same as “restart”.
#
echo -n “Restarting $DESC: ”
start-stop-daemon –stop –quiet –pidfile $PIDFILE –exec $DAEMON
sleep 1
touch_pidfile
start-stop-daemon –start –quiet –pidfile $PIDFILE \
–exec $DAEMON — -D
echo “$NAME.”
;;
*)
N=/etc/init.d/$NAME
# echo “Usage: $N {start|stop|restart|reload|force-reload}” >&2
echo “Usage: $N {start|stop|restart|force-reload}” >&2
exit 1
;;
esac

exit 0

####################################

Даем права на запуск скрипта
chmod +x /etc/init.d/sockd
Рассказываем системе что этот файл нужно исполнять при старте системы
update-rc.d sockd defaults 95


Перезапускаем систему и радуемся результату 

P.S.
Для удаления из автостарта нужно выполнить:


sudo update-rc.d sockd remove

 

Исходники сервера: dante-1.4.0-pre1.tar

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *