iamloco
(usa Ubuntu)
Enviado em 27/10/2011 - 14:55h
Ola, ja testei dns do google e opendns mas nada, como já disse ele não pinga nem o modem oO, como se não enxergasse to passando as regras para dar uma olhada.
#!/bin/bash
iniciar(){
# ETH2: REDE INTERNET
# ETH0: REDE HU
# Limpando as regras
iptables -F
iptables -Z
iptables -t nat -F
iptables -t mangle -F
# Compatilhamento da conexao
echo 1 > /proc/sys/net/ipv4/ip_forward
# Politicas de acesso geral
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
# Manter conexoes ja estabelecidas
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
# Bloqueia pacotes intencionamente mal-formados
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
# Evitando SYN_Flood
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
# Carregamento de Modulos
modprobe ip_nat_ftp
modprobe iptable_nat
modprobe ip_tables
modprobe ip_conntrack
modprobe ipt_MASQUERADE
modprobe ip_conntrack_ftp
# Aceita todo o trafego vindo do loopback e indo pro loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
# Protecoes contra ataques #
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A INPUT -i eth0 -s ! 192.168.2.0/24 -j DROP
# CONECTIVIDADE SOCIAL CAIXA
iptables -A FORWARD -s 192.168.2.0 -p TCP -d 200.201.174.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.174.0/24 -p tcp -d 192.168.2.0 --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d 200.201.160.0/20 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d 200.252.47.0/24 -j ACCEPT
iptables -A FORWARD -p tcp -d 200.201.160.0/20 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.174.204 --dport 2631 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.174.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.174.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.173.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.173.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.163.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.163.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.164.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.164.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.168.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.168.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.2.0/24 -p tcp -d 200.201.166.0/24 --dport 80 -j ACCEPT
iptables -A FORWARD -s 200.201.166.0/24 -p tcp -d 192.168.2.0/24 --dport 80 -j ACCEPT
# BLOQUEIO DE SITES
for end in `cat /etc/squid/rules/iptables`
do
iptables -A OUTPUT -d $end -j REJECT
iptables -A FORWARD -d $end -j REJECT
done
# BLOQUEIO DO FACEBOOK
iptables -A FORWARD -d 65.201.208.24/29 -j REJECT
iptables -A FORWARD -d 65.204.104.128/28 -j REJECT
iptables -A FORWARD -d 66.93.78.176/29 -j REJECT
iptables -A FORWARD -d 66.92.180.48/28 -j REJECT
iptables -A FORWARD -d 67.200.105.48/30 -j REJECT
iptables -A FORWARD -d 69.63.176.0/20 -j REJECT
iptables -A FORWARD -d 69.171.224.0/19 -j REJECT
iptables -A FORWARD -d 74.119.76.0/22 -j REJECT
iptables -A FORWARD -d 204.15.20.0/22 -j REJECT
iptables -A FORWARD -d 204.15.20.0/22 -j REJECT
iptables -A FORWARD -d 66.220.144.0/20 -j REJECT
iptables -A FORWARD -d 173.252.64.0/18 -j REJECT
iptables -A OUTPUT -d 65.201.208.24/29 -j REJECT
iptables -A OUTPUT -d 65.204.104.128/28 -j REJECT
iptables -A OUTPUT -d 66.93.78.176/29 -j REJECT
iptables -A OUTPUT -d 66.92.180.48/28 -j REJECT
iptables -A OUTPUT -d 67.200.105.48/30 -j REJECT
iptables -A OUTPUT -d 69.63.176.0/20 -j REJECT
iptables -A OUTPUT -d 69.171.224.0/19 -j REJECT
iptables -A OUTPUT -d 74.119.76.0/22 -j REJECT
iptables -A OUTPUT -d 204.15.20.0/22 -j REJECT
iptables -A OUTPUT -d 204.15.20.0/22 -j REJECT
iptables -A OUTPUT -d 66.220.144.0/20 -j REJECT
iptables -A OUTPUT -d 173.252.64.0/18 -j REJECT
# DNS
iptables -A INPUT -p udp -s 200.175.182.139 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 200.175.5.139 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 8.8.8.8 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 8.8.4.4 --sport 53 -j ACCEPT
# IPS BLOQUEADOS
iptables -A INPUT -s 192.168.2.100 -j REJECT
iptables -A OUTPUT -s 192.168.2.100 -j REJECT
iptables -A FORWARD -s 192.168.2.100 -j REJECT
iptables -A INPUT -s 192.168.2.33 -j REJECT
iptables -A OUTPUT -s 192.168.2.33 -j REJECT
iptables -A FORWARD -s 192.168.2.33 -j REJECT
iptables -A INPUT -s 192.168.2.177 -j REJECT
iptables -A OUTPUT -s 192.168.2.177 -j REJECT
iptables -A FORWARD -s 192.168.2.177 -j REJECT
iptables -A INPUT -s 192.168.2.229 -j REJECT
iptables -A OUTPUT -s 192.168.2.229 -j REJECT
iptables -A FORWARD -s 192.168.2.229 -j REJECT
iptables -A OUTPUT -s 192.168.2.242 -j REJECT
iptables -A FORWARD -s 192.168.2.242 -j REJECT
iptables -A INPUT -s 192.168.2.242 -j REJECT
iptables -A INPUT -s 192.168.2.179 -j REJECT
iptables -A FORWARD -s 192.168.2.179 -j REJECT
iptables -A OUTPUT -s 192.168.2.179 -j REJECT
# GOOGLE TALK
iptables -A FORWARD -d talk.l.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d chatenabled.mail.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d talk.l.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d chatenabled.mail.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d talk.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d talkx.l.google.com -p tcp --dport 443 -j DROP
iptables -A FORWARD -d talk.l.google.com -p tcp --dport 5222 -j DROP
iptables -A FORWARD -d chatenabled.mail.google.com -p tcp --dport 5222 -j DROP
iptables -A FORWARD -d talk.google.com -p tcp --dport 5222 -j DROP
iptables -A FORWARD -d talkx.l.google.com -p tcp --dport 5222 -j DROP
# UPTODATE
iptables -t nat -A PREROUTING -i eth0 -s 0/0 -d 12.130.132.46/32 -p tcp --dport 80 -j DNAT --to 200.217.177.4:3128
iptables -t nat -A PREROUTING -i eth0 -s 0/0 -d 199.107.238.0/32 -p tcp --dport 80 -j DNAT --to 200.217.177.4:3128
iptables -t nat -A PREROUTING -i eth0 -s 0/0 -d
www.uptodate.com -p tcp --dport 80 -j DNAT --to 200.217.177.4:3128
iptables -t nat -A PREROUTING -i eth0 -s 0/0 -d
www.uptodateonline.com -p tcp --dport 80 -j DNAT --to 200.17.170$
# BANRISUL PIN PAD
iptables -A INPUT -i eth2 -p udp -s 192.168.2.28/24 -d 0/0 -j ACCEPT
# TS AMBULATORIO
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30026 -j DNAT --to-destination 192.168.2.88:3389
iptables -A FORWARD -p tcp -i eth2 --dport 30026 -d 192.168.2.88 -j ACCEPT
# MICROSIGA
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 1234 -j DNAT --to-destination 192.168.2.11:1235
iptables -A FORWARD -p tcp -i eth2 --dport 1234 -d 192.168.2.11 -j ACCEPT
# iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30001 -j DNAT --to-destination 192.168.2.11:22
# iptables -A FORWARD -p tcp -i eth2 --dport 30001 -d 192.168.2.11 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30002 -j DNAT --to-destination 192.168.2.11:1235
iptables -A FORWARD -p tcp -i eth2 --dport 30002 -d 192.168.2.11 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30003 -j DNAT --to-destination 192.168.2.11:5432
iptables -A FORWARD -p tcp -i eth2 --dport 30003 -d 192.168.2.11 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30027 -j DNAT --to-destination 192.168.2.11:7890
iptables -A FORWARD -p tcp -i eth2 --dport 30027 -d 192.168.2.11 -j ACCEPT
# SIGH
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30010 -j DNAT --to-destination 192.168.2.3:5432
iptables -A FORWARD -p tcp -i eth2 --dport 30010 -d 192.168.2.3 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30007 -j DNAT --to-destination 192.168.2.32:5900
iptables -A FORWARD -p tcp -i eth2 --dport 30007 -d 192.168.2.32 -j ACCEPT
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30008 -j DNAT --to-destination 192.168.2.32:5432
iptables -A FORWARD -p tcp -i eth2 --dport 30008 -d 192.168.2.32 -j ACCEPT
# SPARK
# iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30023 -j DNAT --to-destination 192.168.2.100:9090
# iptables -A FORWARD -p tcp -i eth2 --dport 30023 -d 192.168.2.100 -j ACCEPT
# iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 30022 -j DNAT --to-destination 192.168.2.100:5222
# iptables -A FORWARD -p tcp -i eth2 --dport 30022 -d 192.168.2.100 -j ACCEPT
# PONTO UCPel
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 1365 -j DNAT --to-destination 192.168.2.147:1365
iptables -A FORWARD -p tcp -i eth2 --dport 1365 -d 192.168.2.147 -j ACCEPT
# SIGH SSH
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 45000 -j DNAT --to-destination 192.168.2.3:22
iptables -A FORWARD -p tcp -i eth2 --dport 45000 -d 192.168.2.3 -j ACCEPT
# PERMITE CONEXOES NA INTERFACE DE REDE
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
iptables -A INPUT -p tcp --dport 3456 -j ACCEPT
iptables -A INPUT -p tcp --dport 9000 -j ACCEPT
iptables -A INPUT -p tcp --dport 9100 -j ACCEPT
iptables -A INPUT -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -p tcp --dport 1158 -j ACCEPT
iptables -A INPUT -p tcp --dport 1234 -j ACCEPT
iptables -A INPUT -p tcp --dport 30001 -j ACCEPT
iptables -A INPUT -p tcp --dport 30002 -j ACCEPT
iptables -A INPUT -p tcp --dport 30003 -j ACCEPT
iptables -A INPUT -p tcp --dport 30027 -j ACCEPT
iptables -A INPUT -p tcp --dport 30026 -j ACCEPT
iptables -A INPUT -p tcp --dport 45000 -j ACCEPT
iptables -A INPUT -p tcp --dport 30022 -j ACCEPT
iptables -A INPUT -p tcp --dport 30023 -j ACCEPT
iptables -A INPUT -p tcp --dport 30010 -j ACCEPT
iptables -A INPUT -p tcp --dport 45000 -j ACCEPT
iptables -A INPUT -p tcp --dport 465 -j ACCEPT
iptables -A INPUT -p udp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp --dport 30010 -j ACCEPT
iptables -A INPUT -p tcp --dport 30007 -j ACCEPT
iptables -A INPUT -p tcp --dport 30008 -j ACCEPT
iptables -A INPUT -p tcp --dport 30026 -j ACCEPT
iptables -A INPUT -p tcp --dport 30035 -j ACCEPT
iptables -A INPUT -p tcp --dport 30036 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 995 -j ACCEPT
iptables -A INPUT -p udp --dport 995 -j ACCEPT
iptables -A INPUT -p tcp --dport 1365 -j ACCEPT
iptables -A INPUT -p tcp --dport 7890 -j ACCEPT
# INPUT # Pacotes que entram na rede
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT # SSH
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT # HTTP
iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT # HTTPS
iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT
# FORWARD # Pacotes que circulam na rede
iptables -A FORWARD -i eth0 -p tcp --dport 22 -j ACCEPT # SSH
iptables -A FORWARD -i eth0 -p tcp --dport 8333 -j ACCEPT # HTTP
iptables -A FORWARD -i eth0 -p tcp --dport 443 -j ACCEPT # HTTPS
iptables -A FORWARD -i eth0 -p udp --dport 53 -j ACCEPT # DNS
iptables -A FORWARD -i eth0 -p tcp --dport 53 -j ACCEPT # DNS
iptables -A FORWARD -i eth0 -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -i eth0 -o eth2 -j ACCEPT
# COMPARTILHA A CONEXAO
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
echo "Compartilhamento ativado"
# PROXY TRANSPARENTE
iptables -t nat -A PREROUTING -s 192.168.2.0 -d ! 200.201.174.0/24 -p TCP --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
echo "Proxy transparente ativado"
# Proteções diversas contra portscanners, ping of death, ataques DoS, etc.
# iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
# iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s
# iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
# iptables -A FORWARD -m unclean -j DROP
# Abre para a interface de loopback.
# Abre para a interface de loopback.
# iptables -A INPUT -i lo -j ACCEPT
echo "REGRAS DE FIREWALL ATIVADAS"
echo "FEITO POR GIANCARLO GARCIA FLEIGEL EM 17/07/2011"
}
parar(){
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
echo 0 > /proc/sys/net/ipv4/ip_forward
echo "REGRAS DE FIREWALL DESATIVADAS"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar;;
*) echo "Use os parametros start ou stop"
esac
Espero q alguem possa ajudar :D
flw