emerson.cosmo
(usa Debian)
Enviado em 23/06/2009 - 00:09h
Caros, sou novato em linux.
Estou realizando testes para firewall após isso coloco em produção...mais estou com um problema muito chato, não consigo fazer funcionar o RDP(Exemplo, estou em casa e quero acessar meu servidor windows), consigo de casa acessar ssh o firewall, mais RDP não...já configurei apenas o iptables para rdp e nada... segue abaixo meu script.
#!/bin/sh
#############
##variaveis##
#############
iptables=/sbin/iptables
externo=eth0
interno=eth1
###################
##Ativando modulo##
###################
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_MASQUERADE
############################
##Protecao contra spoofing##
############################
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
####################
##Limpando tabelas##
####################
$iptables -F
$iptables -X
$iptables -F -t nat
$iptables -X -t nat
$iptables -X -t mangle
##################################
##Determinando a politica padrao##
##################################
$iptables -P INPUT DROP
$iptables -P OUTPUT DROP
$iptables -P FORWARD DROP
#####################
##Regras de filtros##
#####################
#Aceitar pacotes que realmente devem entrar
#------------------------------------------
$iptables -A INPUT -i ! $externo -j ACCEPT
$iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
$iptables -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
#Protecao contra worms
#----------------------
$iptables -A FORWARD -p tcp --dport 135 -i $interno -j REJECT
#Protecao contra syn-flood
#-------------------------
$iptables -A FORWARD -p tcp --syn -m limit --limit 2/s -j ACCEPT
#Protecao contra port scanners
#------------------------------
$iptables -N SCANNER
$iptables -A SCANNER -j DROP
$iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags ALL NONE -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags ALL ALL -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $externo -j SCANNER
$iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $externo -j SCANNER
#Liberando RDP
$iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
$iptables -A FORWARD -i eth0 -p tcp -d 192.168.10.10 --dport 3389 -j ACCEPT
$iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3389 -j DNAT --to-dest 192.168.10.10:3389
#Liberando acesso externo a determinada porta
$iptables -A INPUT -p tcp --dport 22 -i $externo -j ACCEPT
$iptables -A INPUT -p tcp --dport 22 -i $interno -j ACCEPT
###############
##Tabelas NAT##
###############
#Ativa mascaramento de saida
#----------------------------
#$iptables -A PROSTROUTING -t nat -o $externo -j MASQUERADE