bestmoor
(usa Debian)
Enviado em 22/06/2017 - 11:36h
Bom dia a todos
tenho o seguinte ambiente
Internet dedicada de 60Mb fibra >> Debian 8 (firewall - Iptables ) >> servidores de Terminal Serve (Windows server) portas 3100, 3102, 3900
Por questoes de segurança altero sempre a porta de acesso do TS de 3389 para 3100, 3102 , ...
oque esta acontecente é muito estranho
so consigo acessar um dos servidores os outros nao consigo redirecionar
exemplo
-A PREROUTING -i eth2 -p tcp -m tcp --dport 3102 -j DNAT --to-destination 192.168.1.6:3100
-A PREROUTING -i eth2 -p tcp -m tcp --dport 3100 -j DNAT --to-destination 192.168.1.2:3100
-A PREROUTING -i eth2 -p tcp -m tcp --dport 3900 -j DNAT --to-destination 192.168.1.5:3389
na regra acima so consigo acessar o TS da porta -A PREROUTING -i eth2 -p tcp -m tcp --dport 3102 -j DNAT --to-destination 192.168.1.6:3100 os outros nao funcionam
fiz varias outras combinaçoes e mesmo assim so funciona 1 por vez .
Nos servidores Windows o TS esta ok porque consigo acessar pelas mesmas portas pela rede interna.
somente quando tento externamente passando pelo Iptables é que tenho problema.
ja limpei as regras do firewall mais o erro persiste sera que alguem consegue me dar uma luz
segue regras completas
#!/bin/sh
### BEGIN INIT INFO
# Provides: dovecot
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: firewall iptables protecao
### END INIT INFO
#######################
### Variaveis ###
#######################
rede_externa="eth2"
rede_externa2="eth0"
rede_interna="eth1"
#/sbin/modprobe iptable_nat
iptables -F
iptables -t nat -F
modprobe iptable_nat
### bloqueio de peer and peer
#iptables -A FORWARD -p tcp -m ipp2p --edk -j DROP
#iptables -A FORWARD -p udp -m ipp2p --edk -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --dc -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --kazaa -j DROP
#iptables -A FORWARD -p udp -m ipp2p --kazaa -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --gnu -j DROP
#iptables -A FORWARD -p udp -m ipp2p --gnu -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --bit -j DROP
#iptables -A FORWARD -p udp -m ipp2p --bit -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --apple -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --winmx -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --soul -j DROP
#iptables -A FORWARD -p tcp -m ipp2p --ares -j DROP
################# REDIRECIONANDO PORTA P/ SQUID E COMPARTILHAOD INTERNET #####################
#iptables -t nat -A PREROUTING -i $rede_interna -p tcp --dport 80 -j REDIRECT --to-port 3128
#iptables -t nat -A PREROUTING -i $rede_interna -p tcp --dport 443 -j REDIRECT --to-port 3129
iptables -t nat -A POSTROUTING -o $rede_externa2 -j MASQUERADE
iptables -t nat -A POSTROUTING -o $rede_externa -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
################# REDIRECIONANDO PORTAS #####################
#iptables -A FORWARD -i eth2 -p tcp --dport 3100 -j ACCEPT
#iptables -A FORWARD -i eth2 -p tcp --dport 3101 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 3102 -j DNAT --to 192.168.1.6:3100
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3120 -j DNAT --to 192.168.1.6:3102
#iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 2999 -j DNAT --to 192.168.1.5:3389
#iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 3900 -j DNAT --to 192.168.1.5:3389
#iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 3100 -j DNAT --to 192.168.1.3:3100
iptables -t nat -A PREROUTING -i eth2 -p tcp -m tcp --dport 3100 -j DNAT --to-destination 192.168.1.2:3100
iptables -t nat -A PREROUTING -i $rede_externa -p tcp --dport 3900 -j DNAT --to 192.168.1.5:3389
#iptables -t nat -A PREROUTING -i $rede_externa2 -p tcp --dport 3102 -j DNAT --to 192.168.1.6:3100
#iptables -t nat -A PREROUTING -i $rede_externa2 -p tcp --dport 3101 -j DNAT --to 192.168.1.5:3389
##log ativar somente para depuracao. porque pode deixar o log do kernel gigantesco
#iptables -A INPUT -j LOG
#iptables -A FORWARD -j LOG
#iptables -A OUTPUT -j LOG
################# Bloqueio de acesso ssh brutal force #####################
iptables -I INPUT -p tcp --dport 22 -i eth2 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth2 -m state --state NEW -m recent --update --seconds 600 --hitcount 4 -j DROP
iptables -I INPUT -p tcp --dport 22 -i eth1 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth1 -m state --state NEW -m recent --update --seconds 600 --hitcount 4 -j DROP
iptables -A INPUT -s 58.218.204.181 -j DROP
################# BLOQUEANDO REDE ####################################################
# chamado dos ips para liberacao
#for t in `cat /etc/squid3/ips_liberados` ; do
#libera ips do firewall
#iptables -A FORWARD -d $t -j ACCEPT
#iptables -A FORWARD -s $t -j ACCEPT
################# rede social ####################################################
# registrar log facebook
#iptables -A FORWARD -i $rede_interna -m string --algo bm --string "facebook.com" -j LOG --log-level 6 --log-prefix "FIREWALL: facebook: "
#iptables -A FORWARD -i $rede_interna -m string --algo bm --string "facebook.com" -j DROP
#iptables -A FORWARD -i $rede_interna -m string --algo bm --string "twitter.com" -j DROP
#iptables -A FORWARD -i $rede_interna -m string --algo bm --string "instagram" -j DROP
#libera faixa de ips
#iptables -I FORWARD -m iprange --src-range 10.0.0.1-10.0.0.10 -m string --algo kmp --string "facebook.com" -j ACCEPT
#iptables -I OUTPUT -m iprange --src-range 10.0.0.1-10.0.0.10 -m string --algo kmp --string "facebook.com" -j ACCEPT
#done
#WWWWWWWWWWWWWWWWWWWWWW Bloqueio Wattsapp #WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
#iptables -A FORWARD -p tcp --dport xmpp-client -j DROP
#iptables -A FORWARD -m string --algo bm --string "whatsapp.com" -j DROP
#iptables -A FORWARD -p tcp --dport 5222 -j REJECT
#iptables -A FORWARD -p tcp --dport 5223 -j REJECT
#for zazap in `cat /etc/squid3/ip_what`;do
#iptables -A FORWARD -p tcp -d $zazap --dport 443 -j DROP
######### Liberando whats por mac antes do done ####
#for cel in `cat /etc/squid3/cel_mac`;do
#iptables -I FORWARD -m mac --mac-source $cel -d $zazap -j ACCEPT
#done
#done
####################################################################################
exit 0