gustavo-agm
(usa Debian)
Enviado em 19/12/2012 - 14:58h
Pronto, dei uma arrumada, ficou assim.
Não sei se arrumei da forma mais exata, mas...
#!bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ipt_REDIRECT
modprobe ipt_REJECT
modprobe ip_conntrack
modprobe ip_conntrack_ftp
#
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#FTP externo
iptables -t filter -A INPUT -i eth4 -p tcp -m multiport --dports 2121,20 -j ACCEPT
iptables -t filter -A INPUT -i eth4 -p udp -m multiport --sports 2121,20 -j ACCEPT
#NAT
#Masquerade
iptables -t nat -A POSTROUTING -d 192.168.0.90 -j MASQUERADE
#iptables -t nat -A PREROUTING --proto tcp -i eth4 --dport 2121 -j DNAT --to 192.168.0.90:2121
#NAT GLOBAL
iptables -t nat -A POSTROUTING -o eth4 -j MASQUERADE
#Jogando o tráfego da porta 80 para o squid 3 TRANSPARENT
iptables -t nat -A PREROUTING -i eth5 -p tcp --dport 80 -j REDIRECT --to-pORT 3128
#INPUT
#Limite contra ping da morte DoS (input)
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 1/s -j DROP
#Liberando portas SSH a partir de qualquer interface
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#Liberando Porta VNC
iptables -A INPUT -p udp --dport 5900 -j ACCEPT
#Abre a rede local (input)
iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -d 192.168.0.0/24 -j ACCEPT
#Liberando portas
iptables -A INPUT -p tcp --dport 3128 -i eth5 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -i eth5 -j ACCEPT
iptables -A INPUT -p tcp --dport 183 -i eth5 -j ACCEPT
iptables -A INPUT -p udp --dport 3128 -i eth5 -j ACCEPT
#FTP externo (input)
iptables -A INPUT -i lo-j ACCEPT
iptables -A INPUT -i eth5 -j ACCEPT
iptables -I INPUT -p tcp --dport 2121 -j ACCEPT
iptables -I INPUT -p tcp --dport 20 -j ACCEPT
iptables -I INPUT -p udp --dport 2121 -j ACCEPT
iptables -I INPUT -p udp --dport 20 -j ACCEPT
#iptables -I INPUT -p tcp -m multiport --dports 49152:49162 -j ACCEPT
iptables -I FORWARD -p tcp --dport 2121 -j ACCEPT
#Liberando DNS
iptables -A INPUT -p tcp -m multiport --sports 53,5353 -j ACCEPT
iptables -A INPUT -p udp -m multiport --sports 53,5353 -j ACCEPT
#OUTPUT
#Liberando Porta VNC (output)
iptables -A OUTPUT -p udp --dport 5900 -j ACCEPT
#FORWARD
#LIBERANDO PORTA VNC PARA TODOS (forward)
iptables -A FORWARD -p tcp --dport 5900 -j ACCEPT
#Abre rede local (forward)
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
#FTP acesso interno (forward)
iptables -A FORWARD -p tcp -s eth5 -d 192.168.0.90 --dport 21 -j ACCEPT
iptables -A FORWARD -p tcp -s eth5 -d 192.168.0.90 --dport 20 -j ACCEPT
iptables -A FORWARD -p tcp -s eth5 -d 192.168.0.90 --dport 53 -j ACCEPT
iptables -A FORWARD -p udp -s eth5 -d 192.168.0.90 --dport 53 -j ACCEPT