diegobnx
(usa Debian)
Enviado em 07/10/2010 - 14:05h
ai ta minhas regras
#!/bin/sh
#Iniciando
echo 1 > /proc/sys/net/ipv4/ip_forward
# Mudando as politicas para ACCEPT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
# Limpando as regras em memoria
iptables -F -t filter
iptables -F -t mangle
iptables -F -t nat
iptables -X -t filter
iptables -X -t mangle
iptables -X -t nat
iptables -Z -t filter
iptables -Z -t mangle
iptables -Z -t nat
###################################Protecao################################
#Ignora ping
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
#Protecao contra syn floods
echo > 1 /proc/sys/net/ipv4/tcp_syncookies
#Protege contra ping spoofing
echo > 1 /proc/sys/net/ipv4/conf/default/rp_filter
#Descarta pacotes mal formados
iptables -A INPUT -m state --state INVALID -j DROP
###########################################################################
#Carregando Modulos
modprobe ip_tables
modprobe ip_conntrack_pptp
modprobe ip_nat_pptp
modprobe iptable_nat
modprobe iptable_filter
modprobe iptable_mangle
modprobe ipt_REDIRECT
modprobe ipt_LOG
modprobe ip_conntrack
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
#Abre para a interface de loopback
iptables -A INPUT -p tcp -i lo -j ACCEPT
#Libera conexoes ja estabilizadas.
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
#Protege contra SYN FLOODS
iptables -A FORWARD -p tcp --syn -m limit --limit 10/s -j ACCEPT
iptables -A FORWARD -p tcp --syn -j DROP
#Mascarando
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 22 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 25 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 110 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 1723 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.1.101 -o eth0 -p tcp --dport 3389 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 3050 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 10000 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 2631 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 5017 -j MASQUERADE
#Terezinha
iptables -t nat -A POSTROUTING -s 192.168.1.80 -j MASQUERADE
#Liberando/Bloqueando SSH
iptables -A INPUT -s 187.75.148.56 -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s ! 192.168.1.101 -p tcp --dport 22 -j DROP
#Nat para liberar maquina com acesso ao ssh
iptables -t nat -A PREROUTING -s 189.109.68.14 -i eth0 -p tcp --dport 22 -j DNAT --to-dest 192.168.1.250
iptables -t nat -A PREROUTING -s 189.47.163.127 -i eth0 -p tcp --dport 22 -j DNAT --to-dest 192.168.1.250
iptables -t nat -A PREROUTING -s 201.54.4.74 -i eth0 -p tcp --dport 22 -j DNAT --to-dest 192.168.1.250
#Libera/Block VPN
iptables -A INPUT -p tcp --dport 1723 -j DROP
iptables -A INPUT -p 47 -j DROP
#Nat para server VPN
#POSTO PROGRESSO
iptables -t nat -A PREROUTING -s 201.0.145.66 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#POSTO CENTRO
iptables -t nat -A PREROUTING -s 201.0.145.67 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#PSF
iptables -t nat -A PREROUTING -s 201.0.145.65 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#POSTO CORDEIRO
iptables -t nat -A PREROUTING -s 201.0.145.171 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#POSTO ELDORADO
iptables -t nat -A PREROUTING -s 201.0.145.64 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#ZUC
iptables -t nat -A PREROUTING -s 187.39.60.252 -i eth0 -p tcp --dport 1723 -j DNAT --to-dest 192.168.1.101
#Libera Conectividade Social
iptables -t nat -A PREROUTING -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp -d 192.168.1.0/24 --dport 2631 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp -s 192.168.1.0/24 -d 200.201.174.0/24 --dport 2631 -j MASQUERADE
#Libera porta para OUTLOOK
iptables -A FORWARD -p TCP -s 192.168.1.0/24 --dport 25 -j ACCEPT
iptables -A FORWARD -p TCP -s 192.168.1.0/24 --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp --sport 25 -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT
#Bloquear MSN
iptables -A FORWARD -p tcp --dport 1863 -j REJECT
iptables -A FORWARD -d loginnet.passport.com -j REJECT
#Libera conexao remota
#iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
#Nat para server remoto windows 2003/XP
iptables -t nat -A PREROUTING -s 187.75.148.56 -i eth0 -p tcp --dport 3389 -j DNAT --to-dest 192.168.1.101
#iptables -t nat -A PREROUTING -s 189.109.68.14 -i eth0 -p tcp --dport 3389 -j DNAT --to-dest 192.168.1.101
#Libera Firebird
iptables -A INPUT -p tcp --dport 3050 -j ACCEPT
#Nat para server Firebird
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3050 -j DNAT --to-dest IP_DA_MAQ
#Redirecionando porta 80 para o proxy
iptables -t nat -A PREROUTING -s ! 192.168.1.80 -p tcp --dport 80 -j REDIRECT --to-port 3128