diawd
(usa Ubuntu)
Enviado em 14/12/2010 - 11:09h
eu fiz e também não navegou. Estou colocando o meu script abaixo se quiser dar uma olhada.
E muito obrigado pela ajuda viu :)
case "$1" in
start)
iptables -P FORWARD DROP
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
########### Limpa Regras do Iptables ##########
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
############## Carregando Modulos ########
modprobe ip_tables
modprobe iptable_filter
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
############## Redirecionamento de porta do Proxy ###########
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
############ Liberando Portas ##########
# Stateful
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --sport 22 -j ACCEPT
# Terminsl Service
iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -p tcp --dport 3389 -j ACCEPT
# Email
iptables -A FORWARD -p tcp --sport 25 -j ACCEPT # SMTP
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT # POP3
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT # SMTP
iptables -A FORWARD -p tcp --dport 110 -j ACCEPT # POP3
# ftp
iptables -A FORWARD -p tcp --dport 20 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 20 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# DNS
iptables -A FORWARD -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp --sport 53 -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p udp --sport 53 -j ACCEPT
# Internet
iptables -A FORWARD -i eth1 -p tcp --dport 80 -j DROP
#iptables -A FORWARD -p tcp --dport 80 -j ACCEPT
#iptables -A FORWARD -p tcp --sport 80 -j ACCEPT
iptables -A FORWARD -p tcp --sport 443 -j ACCEPT
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8080 -j ACCEPT
iptables -A FORWARD -p tcp --sport 8080 -j ACCEPT
iptables -A INPUT -p tcp -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
# MySQL
iptables -A FORWARD -p tcp --dport 3306 -j ACCEPT
iptables -A FORWARD -p tcp --sport 3306 -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A FORWARD -p icmp -j ACCEPT
iptables -A INPUT -p icmp -j DROP
;;
stop)
iptables -F
;;
status)
echo ""
echo "Tabela Filter"
echo ""
iptables -L -n
echo ""
echo "Tabela NAT"
echo ""
iptables -t nat -L -n
echo ""
echo "Tabela Mangle"
echo ""
iptables -t mangle -L -n
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usar: $0 {start|stop|status|restart|}"
exit 1
;;
esac
exit $?