Postado originalmente por
bau
Então vou postar meu script aqui para que vc´s possam dar uma olhada e opinar.
VERSION="1.0"
WHICH="/usr/bin/which"
UNAME="`$WHICH uname`"
KERNEL="`$UNAME -r`"
IFCONFIG="`$WHICH ifconfig`"
WHEREIS="$WHICH whereis"
MODPROBE="$WICH modprobe"
# Server Uptime
UPTIME="´uptime | sed 's/ [,]//g' | awk '{print $3}'`"
#echo -e "Server Uptime: $UPTIME"
# Seta qual o path completo do comando iptables
#IPTABLES="/usr/local/sbin/iptables"
IPTABLES"`$WHICH iptables`"
echo -e "\nPath do comando iptables: $IPTABLES\n"
echo "Versão do iptables: `IPTABLES -V`"
echo "Versão do kernel: $KERNEL Server UPtime: $UPTIME"
echo -e "Versão do Firewall Scritp: $VERSION\n"
# Interface de rede conectada a Internet
NET="eth0"
echo " Interface de rede conectada a Internet: $NET"
# Interface de rede conectada a rede local
LAN="eth1"
echo " Interface de rede conectada a rede local: $LAN"
# Interface de rede loopback
LOOP="lo"
echo " Interface de rede loopback: $LOOP"
# Ip da interface de rede conectada a Internet
IPNET="`$IFCONFIG $NET | grep 'inet[^6]' | grep -v ^$NET: | sed 's/[a-zA-Z:]//g' | awk '{print $1}'`"
echo " Endereço IP da interface de rede conectada a internet: $IPNET"
# Mascara de sub-rede da interface de rede conectada a internet
MASKNET="`$IFCONFIG $NET | grep 'Mask[^1]' | grep -v ^$NET: | sed 's/[a-zA-Z:]//g' | awk '{print $3}'`"
# Dados que entraram pela interface de rede conectada a internet
DATAINNET="`ifconfig $NET | grep 'RX bytes' | sed 's/[a-zA-Z()]//g' | awk '{print $2}'`"
DATAINNETSIZE="`ifconfig $NET | grep 'RX bytes' | sed 's/[0-9().:]//g' | awk ' {print $3}'`"
echo -e "Total de dados que entraram pela interface de rede conectada a internet: $DATAINNET $DATAINNETSIZE"
# Dados que sairam pela interface de rede conectada a internet
DATAOUTNET="`ifconfig $NET | grep 'TX bytes' | sed 's/[a-zA-Z()]//g' | awk '{print $4}'`"
DATAOUTNETSIZE="`ifconfig $NET | grep 'TX bytes' | sed 's/[0-9().:]//g' | awk ' {print $6}'`"
echo -e "Total de dados que sairam pela interface de rede conectada a internet: $DATAOUTNET $DATAOUTNETSIZE\n"
# IP da interface de rede conectada a rede local
IPLAN="`$IFCONFIG $LAN | grep 'inet[^6]' | grep -v ^$LAN: | sed 's/[a-zA-Z:]//g' | awk '{print $1}'`"
echo "Endereco ip da interface de rede conectada a rede local: $IPLAN"
# Mascarada de sub-rede da interface conectada a rede local
MASKLAN="`$IFCONFIG $LAN | grep 'Mask[^1]' | grep -v ^$LAN: | sed 's/[a-zA-z:]//g' | awk '{print $3}'`"
# Dados que entraram pela interface de rede conectada a rede local
DATALAN="`ifconfig $LAN | grep 'RX bytes' | sed 's/[a-zA-Z()]//g' | awk '{print $2}'`"
DATAINLANSIZE="`ifconfig $LAN | grep 'RX bytes' | sed 's/[0-9().:]//g' | awk '{print $3}'`"
echo -e "Total de dados que entraram pela interface de rede conectada a redelocal: $DATAINLAN $DATAINLANSIZE"
# Dados que sairam pela interface da rede local
DATAOUTLAN="`ifconfig $LAN | grep 'TX bytes' | sed 's/[a-zA-Z()]//g' | awk '{print $4}'`"
DATAOUTLANSIZE="`ifconfig $LAN | grep 'TX bytes' | sed 's/[0-9().:]//g' | awk '{print $6}'`"
echo -e "Total de dados que sairam pela interface de rede conectada a rede local: $DATAOUTLAN $DATAOUTLANSIZE\n"
# IP da interface Loopback
IPLOOP="`$IFCONFIG $LOOP | grep 'inet[^6]' | grep -v ^$LOOP: | sed 's/[a-zA-Z:]//g' | awk '{print $1}'`"
echo -e "Endereco ip da interface de rede loopback: $IPLOOP\n"
# Mascara de sub-rede da interface de rede loopback
MASKLOOP="`$IFCONFIG $LOOP | grep 'Mask[^1]' | sed 's/[a-zA-Z:]//g' | awk '{print $2}'`"
# Lock File
LOCK_FILE="/var/run/firewall/firewall.run"
# Rede Externa (internet)
OUTNET="$IPNET/$MASKNET"
# Rede local (intranet)
LANNET="$IPLAN/$MASKNET"
# Interface loopback
LOOPNET="$IPLOOP/$MASKLOOP"
# FAixa de IPs da Internet
WEB="0/0"
# DNS Server
DNS="`grep nameserver /etc/resolv.conf | awk '{print $2}' | awk 'getline $1'`"
DNSTMP="/var/run/firewall/dns.tmp"
touch $DNSTMP
echo "0" > $DNSTMP
for i in `grep nameserver /etc/resolv.conf | awk '{print $2}'`
do
expr `cat $DNSTMP` + 1 > $DNSTMP
echo "Endereco IP do Servidor DNS: DNS `cat $DNSTMP` $i"
done
rm $DNSTMP
# Max Error for ping packet loss (10% packet loss)
MAX_ERROR="10"
# Blocked IPs
STUPIDFILTER_LIST="/etc/firewall/blocked/stupidfilter"
# Blocked Sites
SITE_LIST="/etc/firewall/blocked/sites"
# Blocked WormFilter
WORMFILTER_LIST="/etc/firewall/blocked/wormfilter"
# Blocked WEBFILTER
WEBFILTER_LIST="/etc/firewall/blocked/webfilter"
STRING_LIST="/etc/firewall/blocked/strings"
# Load Iptables Modules
$MODPROBE ipt_contrack
$MODPROBE ip_contrack
$MODPROBE ip_contrack_ftp
$MODPROBE ip_contrack_irc
$MODPROBE ip_nat_ftp
$MODPROBE ip_nat_irc
$MODPROBE ip_nat_snmp_basic
##########################################-----Limpando Regras------############################################
# Limpando Regras Existentes
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD
$IPTABLES -t -nat -F
#########################################------INPUT--------####################################################
# Determinando Politica padrão
$IPTABLES -P INPUT DROP
# Bloqueia IPs estupidos! por tentativas diversas
$IPTABLES -N STUPIDFILTER
$IPTABLES -A STUPIDFILTER -j DROP
for BLOCKED_STUPIDFILTER in `grep -v ^# $STUPIDFILTER_LIST`
do
$IPTABLES -A INPUT -p tcp -s $BLOCKED_STUPIDFILTER -d $IPNET -j REJECT
$IPTABLES -A INPUT -p udp -s $BLOCKED_STUPIDFILTER -d $IPNET -j REJECT
echo "IP Bloqueado pelo STUPIDFILTER: $BLOCKED_STUPIDFILTER"
done
# Bloqueia pacotes fragmentados
$IPTABLES -A INPUT -i $NET -f -j DROP
# Bloqueia qualquer tentativa de conexao de fora para dentro por TCP
$IPTABLES -A INPUT -i $NET -p tcp --syn -j DROP
# Protecao contra ataques
$IPTABLES -A INPUT -m state --state INVALID -j DROP
# Aceita os pacotes que realmente devem aceitar
$IPTABLES -A INPUT -i ! $NET -j ACCEPT
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Acabando com sessoes mortas
$IPTABLES -A INPUT -m limit --limit 3/minute --limit-burst 3 -j DROP
#Bloqueando Traceroute
$IPTABLES -A INPUT -p udp -s $WEB -i $NET --dport 33435:33525 -j DROP
#Bloqueando uma máquina pelo endereço MAC
#$IPTABLES -A INPUT -m mac --mac-source XX:XX:XX:XX:XX:XX -j DROP
# Dropando pacotes TCP mal formados
$IPTABLES -N BAD_TCP_PACKETS
$IPTABLES -A BAD_TCP_PACKETS -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "Pacotes TCP mal formados!"
$IPTABLES -A BAD_TCP_PACKETS -p tcp ! --syn -m state --state NEW -j DROP
#WORMFILTER
$IPTABLES -N WORMFILTER
$IPTABLES -A WORMFILTER -j REJECT
# Bloqueia todos os IP logados pelo WORMFILTER
for BLOCKED_WORMFILTER in `grep -v ^# $WORMFILTER_LIST`
do
$IPTABLES -A INPUT -p tcp -s $BLOCKED_WORMFILTER -i $NET --dport 80 -j WORMFILTER
echo " IP Bloqueado pelo WORMFILTER: $BLOCKED_WORMFILTER"
done
# Protecao contra Port Scanners
$IPTABLES -N SCANNER
$IPTABLES -A SCANNER -m limit --limit 15/m -j LOG --log-level 6 --log-prefix "FIREWALL: Port Scanner"
$IPTABLES -A SCANNER -j DROP
$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $NET -j SCANNER
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $NET -j SCANNER
# Esse passo foi tirado do Arno IPTABLES FIREWALL
$IPTABLES -N VALID_CHECK
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN, RST SYN, RST -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN, FIN SYN, FIN -j DROP
$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP
# Liberar Acesso externo a determinadas portas Iniciam como REJECT,
# Mas se precisar liberar, basta mudar para ACCEPT
#FTP
$IPTABLES -A INPUT -p tcp --dport 21 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 21 -i $NET -j REJECT
#SSH
$IPTABLES -A INPUT -p tcp --dport 22 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 22 -i $NET -j REJECT
#SMTP
$IPTABLES -A INPUT -p tcp --dport 25 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 25 -i $NET -j REJECT
#TIME
$IPTABLES -A INPUT -p tcp --dport 37 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 37 -i $NET -j REJECT
#DNS
$IPTABLES -A INPUT -p tcp --dport 53 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 53 -i $NET -j REJECT
#WWW
$IPTABLES -A INPUT -p tcp --dport 80 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 80 -i $NET -j REJECT
#POP3
$IPTABLES -A INPUT -p tcp --dport 110 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 110 -i $NET -i REJECT
#IDENTD
$IPTABLES -A INPUT -p tcp --dport 113 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 113 -i $NET -j REJECT
#IMAP
$IPTABLES -A INPUT -p tcp --dport 143 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 143 -i $NET -j REJECT
#SMTP Sendmail
$IPTABLES -A INPUT -p tcp --dport 587 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 587 -i $NET -j REJECT
#IMAPS
$IPTABLES -A INPUT -p tcp --dport 993 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 993 -i $NET -j REJECT
#POP3S
$IPTABLES -A INPUT -p tcp --dport 995 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 995 -i $NET -j REJECT
#X11
$IPTABLES -A INPUT -p tcp --dport 6000 -i $LAN -j REJECT
$IPTABLES -A INPUT -p tcp --dport 6000 -i $NET -j REJECT
#Protecao contra IP Spoonfing
$IPTABLES -A INPUT -s 1.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 2.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 7.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 10.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 10.0.0.0/255.0.0.0 -i $NET -j DROP
$IPTABLES -A INPUT -s 23.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 27.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 31.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 41.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 45.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 60.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 68.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 69.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 70.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 71.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 80.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 88.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 90.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 91.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 92.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 100.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 111.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 112.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 127.0.0.0/8 -i $NET -j DROP
$IPTABLES -A INPUT -s 128.66.0.0/16 -i $NET -j DROp
$IPTABLES -A INPUT -s 172.0.0.0/255.0.0.0 -i $NET -j DROP
$IPTABLES -A INPUT -s 172.16.0.0/12 -i $NET -j DROP
$IPTABLES -A INPUT -s 192.168.0.0/16 -i $NET -j DROP
$IPTABLES -A INPUT -s 197.0.0.0/16 -i $NET -j DROP
$IPTABLES -A INPUT -s 255.255.255.255 -i $NET -j DROP
# Protecao contra o acesso externo a servicos telnet
$IPTABLES -A INPUT -p tcp -i $NET -d $LANNET --dport 23 -j DROP
# Protecao contra o acesso externo ao netbios
$IPTABLES -A INPUT -p tcp -i $NET -d $LANNET --dport 137:139 -j DROP
# Protecao contra o acesso interno com netbios
$IPTABLES -A INPUT -p tcp -i $LANNET -d $NET --dport 137:139 -j DROP
# Libera acesso interno da rede
$IPTABLES -A INPUT -p tcp --syn -s $LANNET -j ACCEPT
# Libera ping 'restrinto'
$IPTABLES -A INPUT -p icmp --icmp-type 8 -i $NET -j ACCEPT
$IPTABLES -A INPUT -p icmp --icmp-type 0 -i $NET -j ACCEPT
$IPTABLES -A INPUT -p icmp -s $LANNET -d $WEB -j ACCEPT
# Bloqueia tudo que nao estiver especificado acima
$IPTABLES -A INPUT -p tcp --syn -j DROP
$IPTABLES -A INPUT -p udp -j DROP
#############################################-------OUTPUT-------#################################################
# Agora inicia o chain OUTPUT
# Aceita os pacotes que realmente devem entrar
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
# Perfomance - Setando acesso a web com delay minimo
$IPTABLES -t mangle -A OUTPUT -o $NET -p tcp --dport 53 -j TOS --set-tos Minimize-Delay
$IPTABLES -t mangle -A OUTPUT -o $NET -p tcp --dport 80 -j TOS --set-tos Minimize-Delay
# Liberando Acesso Interno a rede
$IPTABLES -A OUTPUT -p tcp --syn -s $LANNET -j ACCECPT
# Liberando Acesso loopback
$IPTABLES -A OUTPUT -p tcp --syn -s $LANNET -j ACCEPT
#Bloqueia o resto
$IPTABLES -A OUTPUT -p tcp --syn -j DROP
$IPTABLES -A OUTPUT -p udp -j DROP
######################################----------FORWARD------####################################################
# Inicio da chain FORWARD
# Dropa pacotes invalidos
$IPTABLES -A FORWARD -m state --state INVALID -j DROP
# Dropa pacotes TCP indesejaveis
$IPTABLES -A FORWARD -p tcp ! --syn -m state --state NEW -j DROP
# Aceita os pacotes que realmente devem passar
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j DROP
# Protecao contra Worms
$IPTABLES -A FORWARD -p tcp --dport 135 -i $LAN -j REJECT
# Protecao contra syn-flood
$IPTABLES -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
# Protecao contra ping da morte
$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
# Protecao contra port scanners avancados (ex.: namp)
$IPTABLES -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
# Protecao contra pacotes que podem procurar obter informacoes da rede interna
$IPTABLES -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
# Bloqueando redes P2P
#imesh
$IPTABLES -A FORWARD -d 216.35.208.0/24 -j REJECT
#BearShare and Toad Node
$IPTABLES -A FORWARD -p tcp --dpot 6346 -j REJECT
#WinMX
$IPTABLES -A FORWARD -d 209.61.186.0/24 -j REJECT
$IPTABLES -A FORWARD -d 64.49.201.0/24 -j REJECT
# Napigator
$IPTABLES -A FORWARD -d 209.25.178.0/24 -j REJECT
#Morpheus
$IPTABLES -A FORWARD -d 206.142.53.0/24 -j REJECT
$IPTABLES -A FORWARD -p TCP --dport 1214 -j REJECT
# Kazza
$IPTABLES -A FORWARD -d 213.248.112.0/24 -j REJECT
$IPTABLES -A FORWARD -p TCP --dport 1214 -j REJECT
# Limewire
$IPTABLES -A FORWARD -p TCP --dport 6346 -j REJECT
# Audiogalaxy
$IPTABLES -A FORWARD -d 64.245.58.0/23 -j REJECT
# GNUTELLA
$IPTABLES -A FORWARD -p tcp --dport 6346 -j REJECT
# eDonkey
$IPTABLES -A FORWARD -p tcp --dport 4661:4662 -j REJECT
$IPTABLES -A FORWARD -p udp --dport 4665 -j REJECT
# Bloquando Servicos de Mensagens Intantaneas
#AIM
$IPTABLES -A FORWARD -d login.oscar.aol.com -j REJECT
#ICQ
$IPTABLES -A FORWARD -p TCP --dport 5190 -j REJECT
$IPTABLES -A FORWARD -d login.icq.com -j REJECT
#MSN
$IPTABLES -A FORWARD -p TCP --dport 1863 -j REJECT
$IPTABLES -A FORWARD -d 64.4.13.0/24 -j REJECT
# Yahoo Messenger
$IPTABLES -A FORWARD -d cs.yahoo.com -j REJECT
#Libera acesso interno da Rede
$IPTABLES -A FORWARD -p tcp --syn -s $LANNET -j ACCEPT
#WEBFILTER
$IPTABLES -N WEBFILTER
$IPTABLES -A WEBFILTER -j REJECT
# Bloqueia todos os ip´s logados pelo WEBFILTER
for BLOCKED_WEBFILTER in `grep -v ^# $WEBFILTER_LIST`
do
$IPTABLES -A FORWARD -p tcp -s $LANNET -d $BLOCKED_WEBFILTER --dport 80 -j WEBFILTER
$IPTABLES -A FORWARD -p tcp -s $LANNET -d BLOCKED_WEBFILTER --dport 1080 -j WEBFILTER
echo " IP Bloqueado pelo WEBFILTER: $BLOCKED_WEBFILTER"
done
# Bloqueia String maliciosas pelo WEBFILTER
# Necessita do Modulo 'string' do pactch-o-matic compilado
#for BLOCKED_STRING in `grep -v ^# $STRING_LIST`
#do
# $IPTABLES -A FORWARD -p tcp -m string --string "BLOCKED_STRING" -j WEBFILTER
# echo " String Bloqueada pelo WEBFILTER: $BLOCKED_STRING"
#done
# Aqui devo habilitar a passagem dos pacotes NAT para IPs full que passaram fora do proxy
# Ver tabela abaixo NAT onde informa o IP liberado
#$IPTABLES -A FORWARD -p tcp -s xxx.xxx.xxx.xxx -d $NET -j ACCEPT
# Bloqueia tudo que nao estiver especificado acima
$IPTABLES -A FORWARD -p tcp --syn -j DROP
$IPTABLES -A FORWARD -p udp -j DROP
################################################-------NAT-------################################################
# Aqui Inicia a Chain NAT
# Exemplos
# Habilitando o mascaramento de saida
$IPTABLES -t -nat -A POSTROUTING -o $NET -j MASQUERADE
# Nessa Chain passara o IP informado fora do Proxy como full
#$IPTABLES -t nat -A POSTROUTING -s xxx.xxx.xxx.xxx -o $NET -j MASQUERADE
# Regras para redirecionar portas e ips que estao saindo
#$IPTABLES -t -nat -A PRETOURING -p tcp --dport 25 -j REDIRECT --to-port 25
# Exemplos
# Redireciona a porta 25 do smtp para esta maquina 192.168.xxxxxxx:25
#$IPTABLES -t -nat -A PREROUTING -p tcp --dport 25 -j DNAT --to 192.168.xxxxx:25
# Redireciona o trafego http para alpha.algumacoisa.no-ip.org
#$IPTABLES -t -nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-dest 192.168.xxxxx
# Redireciona a porta 25 do smtp para o servidor wwww.algumacoisa.com.br com ip xxx.xxx.xxx.xxx:25
#$IPTABLES -t -nat -A PREROUTING -p tcp --dport 25 -j DNAT --to xxx.xxx.xxx.xxx:25
# Redireciona o trafego web para o proxy transparente
#$IPTABLES -t -nat -A PREROUTING -i $LANNET -p tcp --dport 80 -j REDIRECT --to-port 3128
#$IPTABLES -t -nat -A PREROUTING -i $LANNET -p tcp --dport 8080 -j REDIRECT --to-port 3128
#SERVIDOR_SMTP_LOCAL="false"
# se possuir servidor smtp LOCAL na maquina, habilite o 'transparent
# proxy' do SMTP, permitindo assim que qualquer acesso a servidores SMTP
# externos sejam atendidos pelo servidor local
# Basta colocar o IP aqui para passar pelo transparente proxy
# defina enderecos IPs que nao devem passar pelo transparent proxy
# 200.244.136.0/24 = dataprev homepage, usa 8080
# 200.246.143.0/24 = itau software de internet banking
#BYPASS_TRANSPARENT_PROXY="200.244.136.0/24 200.246.143.0/24 192.168.30.1"
# Transparent Proxy ( interface INTERNA )
# IPs que nao devem passar no Transparent Proxy
#for endereco in $BYPASS_TRANSPARENT_PROXY;
#do
# $IPTABLES -t nat -A PREROUTING -p tcp -i $LANNET -d $NET --dport 80 -j ACCEPT
#done
# agora sim, transparent proxy pra galera !!!#
#$IPTABLES -t nat -A PREROUTING -p tcp -i $LANNET --dport 80 -j REDIRECT --to-port 8080
#$IPTABLES -t nat -A PREROUTING -p tcp -i $LANNET --dport 3128 -j REDIRECT --to-port 8080#
#$IPTABLES -t nat -A PREROUTING -p tcp -i $LANNET --dport 8080 -j REDIRECT --to-port 8080
# redirecionando SMTP para servidor smtp local ( interface INTERNA )
#if [ $SERVIDOR_SMTP_LOCAL == "true" ]; then
#$IPTABLES -t nat -A PREROUTING -p tcp -i $LANNET --dport 25 -j REDIRECT --to-port 25
# Aqui vc devera colocar o ip para ser liberado a net
#endereco="192.168.0.0 192.168.0.1"
# Liberando NAT para alguns IPs especiais
#for endereco in $NAT_LIBERADO;
#do
#$IPTABLES -t nat -A POSTROUTING -s $endereco -o $NET -m state --state NEW,ESTABLISHED,RELATED -j SNAT --to-source $NET
#done
# IPs que nao devem passar no Transparent Proxy
#for endereco in $BYPASS_TRANSPARENT_PROXY;
#do
#$IPTABLES -t nat -A POSTROUTING -p tcp -o $NET -d $endereco --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j SNAT --to-source $NET
#done
# Redireciona espertinhos para o site qqer.
#$IPTABLES -t -nat -A PREROUTING -s 192.168.xxx.xxx -d $WEB -j DNAT --to-destinantion $IPLAN
#############################################-------FIM-------####################################################
As informações estão nas chain´s FORWARD e NAT....
[ ] ´s
Bau[/u][/b]