ejuniorguitar
(usa Fedora)
Enviado em 22/03/2011 - 10:31h
Bom dia a todos!
Gostaria de saber o que há de errado neste script...
Ah eu tenho duas faixas de ip o 192.168.0.1 livre, e o 192.168.2.1 passa pelo squid onde são feitas as restrições...
#!/bin/bash
#####################
#CARREGANDO MODULOS #
#####################
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ipt_conntrack
modprobe ipt_MASQUERADE
modprobe iptable_nat
### LIMPANDO AS TABELAS E REGRAS #####
iptables -F
iptables -t nat -F
iptables -X
##Habilitando IP Forward
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
##########
## NAT ##
##########
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -p 192.168.2.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
####################
#Proxy transparente#
####################
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i 192.168.2.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
#Syn-floods
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
#Port scanners ocultos
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
#Ping da morte
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
##Protege contra Spoof de IP
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
###########################
## Virus Trojans e Afins ##
###########################
# -> Input
#iptables -A INPUT -p tcp --dport 135:139 -j DROP
#iptables -A INPUT -p udp --dport 135:139 -j DROP
#iptables -A INPUT -p tcp --dport 445 -j DROP
#iptables -A INPUT -p udp --dport 445 -j DROP
#iptables -A INPUT -p udp --dport 1042 -j DROP
#iptables -A INPUT -p udp --dport 1044 -j DROP
#iptables -A INPUT -p udp --dport 1046 -j DROP
#iptables -A INPUT -p udp --dport 4672 -j DROP
iptables -A INPUT -p udp --dport 2525 -j ACCEPT
iptables -A INPUT -p tcp --dport 2525 -j ACCEPT
iptables -A INPUT -p udp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp --dport 465 -j ACCEPT
# -> Forward ->
#iptables -A FORWARD -p tcp --dport 135:139 -j DROP
#iptables -A FORWARD -p udp --dport 135:139 -j DROP
#iptables -A FORWARD -p tcp --dport 445 -j DROP
#iptables -A FORWARD -p udp --dport 445 -j DROP
#iptables -A FORWARD -p udp --dport 1042 -j DROP
#iptables -A FORWARD -p udp --dport 1044 -j DROP
#iptables -A FORWARD -p udp --dport 1046 -j DROP
#iptables -A FORWARD -p udp --dport 4672 -j DROP
iptables -A FORWARD -p udp --dport 2525 -j ACCEPT
iptables -A FORWARD -p tcp --dport 2525 -j ACCEPT
iptables -A FORWARD -p udp --dport 465 -j ACCEPT
iptables -A FORWARD -p tcp --dport 465 -j ACCEPT
# -> Output
#iptables -A OUTPUT -p tcp --dport 135:139 -j DROP
#iptables -A OUTPUT -p udp --dport 135:139 -j DROP
#iptables -A OUTPUT -p tcp --dport 445 -j DROP
#iptables -A OUTPUT -p udp --dport 445 -j DROP
#iptables -A OUTPUT -p udp --dport 1042 -j DROP
#iptables -A OUTPUT -p udp --dport 1044 -j DROP
#iptables -A OUTPUT -p udp --dport 1046 -j DROP
#iptables -A OUTPUT -p udp --dport 4672 -j DROP
iptables -A OUTPUT -p udp --dport 2525 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 2525 -j ACCEPT
iptables -A FORWARD -p udp --dport 465 -j ACCEPT
iptables -A FORWARD -p tcp --dport 465 -j ACCEPT
Obrigado!