Я настроил Dante sockd для пересылки трафика через несколько IP-интерфейсов. Конфигурация в основном такая:
logoutput: /var/log/sockd.log
debug: 1
socksmethod: username none
internal: eth0 port = 60000
external: eth0
internal: eth0:0 port = 60000
external: eth0:0
internal: eth0:1 port = 60000
external: eth0:1
internal: eth0:2 port = 60000
external: eth0:2
...
external.rotation: same-same
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
socksmethod: username
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
socksmethod: username
protocol: tcp udp
}
При отключенном 'external.rotation = same.same' трафик проходит через сервер, но выходит только с одного адреса. Когда он включен, я получаю следующую ошибку с помощью curl:
curl: (7) Can't complete SOCKS5 connection to x.x.x.x:80. (3)
и эта ошибка в логах:
May 15 07:38:38 (1431689918.007569) sockd[4887]: info: block(1): tcp/accept ]: x.x.x.x.56066 y.y.y.y.60000: request was not performed due to error: could not get address to use on external side: using external.rotation = same-same, local address x.x.x.x was selected for forwarding from our local client x.x.x.x.56066 to target z.z.z.z.80, but that local address is not set on our external interface(s). Configuration error in /etc/sockd.conf?
xxxx — мой IP-адрес, yyyy — адрес сервера, а zzzz — адрес назначения.
Это говорит мне о том, что сервер рассчитывает выдать себя за мой адрес, но он не настроен. Это правильно, поскольку я хочу, чтобы трафик воспринимался как исходящий с адреса yyyy, а их более сотни, из которых можно выбирать.
Я не могу найти в документации ничего, что соответствовало бы ошибке, которую я вижу, и я подозреваю, что нужна какая-то конфигурация round robin, но я не могу найти и ее. Кто-нибудь сделал это таким образом?
решение1
Следующее сработало у меня с Dante 1.4.2 на CentOS 6.x 64bit, хотя я не использую аутентификацию, поскольку получаю доступ к Dante через SSH-туннели (IP-адреса моего сервера — 1.1.1.1, 2.2.2.2 и 3.3.3.3):
logoutput: syslog stdout stderr /var/log/sockd.log
internal: eth0:0 port = 1080
internal: eth0:1 port = 1080
internal: eth0:2 port = 1080
external: eth0:0
external: eth0:1
external: eth0:2
external.rotation: same-same
user.privileged: root
user.unprivileged: sockd
#user.libwrap: sockd
clientmethod: none
socksmethod: none
client pass {
from: 1.1.1.1/32 to: 0.0.0.0/0
log: error # connect disconnect
}
client pass {
from: 2.2.2.2/32 to: 0.0.0.0/0
log: error # connect disconnect
}
client pass {
from: 3.3.3.3/32 to: 0.0.0.0/0
log: error # connect disconnect
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bind connect udpassociate
log: error # connect disconnect iooperation
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bindreply udpreply
log: error # connect disconnect iooperation
}
Затем создал три локальных туннеля с моей клиентской машины:
ssh -L 10801:1.1.1.1:1080 -L 10802:2.2.2.2:1080 -L 10803:3.3.3.3:1080 [email protected]
Думаю, большинство проблем с настройками были связаны с правами доступа (пароль клиента и пароль socks).
Если у вас все еще возникают проблемы, вы можете попробовать альтернативу Dante: 3Proxy.
Настроить 3proxy можно следующим образом:
nserver 8.8.8.8
auth none
daemon
socks -p1080 -i1.1.1.1 -e1.1.1.1
socks -p1080 -i2.2.2.2 -e2.2.2.2
socks -p1080 -i3.3.3.3 -e3.3.3.3
pidfile /var/run/3proxy.pid
log /dev/null
Надеюсь это поможет.
решение2
Пробовали ли вы включить переадресацию IP для вашей ОС?
sysctl -w net.ipv4.ip_forward=1
или
echo 1 > /proc/sys/net/ipv4/ip_forward
Больше информации @http://linuxconfig.org/how-to-turn-on-off-ip-forwarding-in-linux