hugovlmota
(usa CentOS)
Enviado em 03/08/2007 - 15:14h
segue ai minha regra iptables.
#placa interna =eth0
#placa externa =eth1
# IP do Servidor Web 192.168.1.250
# limpa iptables
iptables -F
iptables -X
iptables -X -t nat
iptables -F -t mangle
iptables -X -t mangle
# ----------------------------------------------------------
# carrega modulos
# ----------------------------------------------------------
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_REJECT
modprobe ipt_MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j REDIRECT --to-port 3128
# ----------------------------------------------------------
# Mascaramento
# ----------------------------------------------------------
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
iptables -A INPUT -p tcp --dport 21 -j LOG --log-prefix "Porta do FTP "
iptables -A INPUT -p tcp --dport 23 -j LOG --log-prefix "Porta do TELNET "
iptables -A INPUT -p tcp --dport 22 -j LOG --log-prefix "Porta do SSH "
iptables -A INPUT -p tcp --dport 137:139 -j LOG --log-prefix "Porta do NETBEUI "
# ----------------------------------------------------------
#loopback
# ----------------------------------------------------------
iptables -A OUTPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT
# ----------------------------------------------------------
#conexões fora->dentro
# ----------------------------------------------------------
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 563 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 563 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# ----------------------------------------------------------
#Correio Eletronico
# ----------------------------------------------------------
iptables -A FORWARD -p tcp -s 192.168.1.0/24 -d 201.7.95.96 --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 -d 201.7.95.96 --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -s 201.7.95.96 --sport 53 -d 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -p tcp -s 201.7.95.96 --sport 53 -d 192.168.1.0/24 -j ACCEPT
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
# ----------------------------------------------------------
#Conectividade Social
# ----------------------------------------------------------
iptables -A FORWARD -p tcp --dport 2631 -j ACCEPT
iptables -A FORWARD -p udp --dport 2631 -j ACCEPT
# ----------------------------------------------------------
#HTTPS
# ----------------------------------------------------------
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp --dport 563 -j ACCEPT
# ----------------------------------------------------------
# conexoes dentro->fora:
# ----------------------------------------------------------
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 20 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 86 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 5190 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 1863 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 110 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 563 -j ACCEPT
# ----------------------------------------------------------