removido
(usa Nenhuma)
Enviado em 29/09/2010 - 23:11h
agr está assim a regra
=================================================
#!/bin/bash
# Comando IPTables
IPTABLES="/usr/sbin/iptables"
# Interface Internet
P1="eth0"
###############################
# FUNÇÕES
case $1 in
start) /etc/rc.d/rc.firewall ;;
restart) /etc/rc.d/rc.firewall ;;
stop) # Limpando as regras em memória
$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
# Mudando as políticas para DROP
$IPTABLES -t filter -P INPUT ACCEPT
$IPTABLES -t filter -P OUTPUT ACCEPT
$IPTABLES -t filter -P FORWARD ACCEPT
;;
'') echo "carregando firewall..." ;;
*) echo "{start|stop|restart}" && exit 1 ;;
esac
##################################################################
# Limpando as regras em memória
$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
# Mudando as políticas para DROP
$IPTABLES -t filter -P INPUT DROP
$IPTABLES -t filter -P OUTPUT DROP
$IPTABLES -t filter -P FORWARD DROP
###################################################################
modprobe nf_nat_ftp
modprobe nf_conntrack_ftp
###################################################################
# INPUT
# Liberar lo
$IPTABLES -A INPUT -i lo -j ACCEPT
# Manter Conexões Estabelecidas
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# FTP ----------------------------------------------------------------------------------
$IPTABLES -A INPUT -i eth0 -p tcp -s 0/0 --dport 21 -j ACCEPT
# Habilita tranferência de FTP ativo
$IPTABLES -A INPUT -i eth0 -p tcp -s 0/0 --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Habilita transferência de FTP passivo
$IPTABLES -A INPUT -i eth0 -p tcp -s 0/0 --sport 1025:65535 --dport 1025:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
# SAMBA ----------------------------------------------------------------------------------
$IPTABLES -A INPUT -i $P1 -p tcp -m multiport --dports 445,139 -j ACCEPT
$IPTABLES -A INPUT -i $P1 -p udp -m multiport --dports 137,138 -j ACCEPT
# CUPS ----------------------------------------------------------------------------------
$IPTABLES -A INPUT -s 192.168.1.0/24 -p tcp --dport 631 -j ACCEPT
# ===============================================================================================================
# OUTPUT
# DNS ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -o $P1 -p tcp -m multiport --dports 53,5353 -j ACCEPT
$IPTABLES -A OUTPUT -o $P1 -p udp -m multiport --dports 53,5353 -j ACCEPT
# HTTP e HTTPS ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -o $P1 -p tcp -m multiport --dports 80,8080,8081,443 -j ACCEPT
# MSN ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -o $P1 -p tcp -m multiport --dports 1863,7001 -j ACCEPT
$IPTABLES -A OUTPUT -o $P1 -p udp --dport 7001 -j ACCEPT
# Gtalk/Jabber ----------------------------------------------------------------------------------
#$IPTABLES -A OUTPUT -o $INET -p tcp --dport 5222 -j ACCEPT
# Ping ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -o $P1 -p icmp --icmp-type 8 -j ACCEPT
# FTP ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -p tcp --dport 21 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --dport 20 -j ACCEPT
# SAMBA ----------------------------------------------------------------------------------
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# ===============================================================================================================
# FOWARD
# Contra DoS: ----------------------------------------------------------------------------------
# Protege contra os ataques do tipo Syn-flood
$IPTABLES -A FORWARD -p tcp --syn -m limit --limit 10/s -j ACCEPT
$IPTABLES -A FORWARD -p tcp --syn -j DROP
# FTP ----------------------------------------------------------------------------------
$IPTABLES -A FORWARD -p tcp -s 192.168.1.0/24 --dport 21 -j ACCEPT
# SAMBA ----------------------------------------------------------------------------------
echo "Iptables...[Ok]"
===================================================
tive que carregar os modulos
modprobe nf_nat_ftp
modprobe nf_conntrack_ftp