Enviado em 12/04/2013 - 17:43h
Buenas pessoALL,
#!/bin/bash
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Firewall Servidor Proxy
# Description: Firewall Servidor Proxy.
### END INIT INFO
# Firewall adaptado por Alex Camacho Castilho
# Data da Criação: 01/2013
firewall_start () {
clear
echo "=============================================================="
echo ":: ATIVANDO O FIREWALL ::"
echo "=============================================================="
### Definição de Variáveis
# Define o local do binário do iptables
ipt="/sbin/iptables"
# Interfaces
wan=em1
lan=eth0
# Portas e Serviços
ftp=20:21
ftp1=20
ftp2=21
smtp=25
smtp2=587
dns=53
dhcp1=67
dhcp2=68
http=80
pop=110
ntp=123
imap=143
snmp=161:162
https=443
portas_altas=1024:65535
squid=3128
squidssl=3129
rip=520
ssh=2222
marcio=44444
alex=55555
nessus=8834
echo "Definindo Variáveis do Firewall.......................... [OK]"
### Carrega Módulos iptables
modprobe ip_tables
modprobe iptable_filter
modprobe iptable_mangle
modprobe iptable_nat
modprobe ipt_MASQUERADE
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ip_conntrack
echo "Carregando Módulos do iptables........................... [OK]"
### Limpa todas as regras do iptables
$ipt -X
$ipt -F
$ipt -Z
$ipt -F INPUT
$ipt -F OUTPUT
$ipt -F FORWARD
$ipt -F -t nat
$ipt -F -t mangle
echo "Limpando todas as regras do iptables..................... [OK]"
# Aceita todas as Conexões para Interface loopback
$ipt -A INPUT -i lo -j ACCEPT
echo "Liberando todas Conexões para loopback................... [OK]"
### Define Política Padrão das Cadeiras
$ipt -P INPUT DROP
$ipt -P FORWARD DROP
$ipt -P OUTPUT ACCEPT
echo "Definindo Política Padrão das Cadeiras................... [OK]"
### Bloqueio Sites Específicos para HTTPS
for IP_FACE in `cat /etc/bloqueio_facebook`
do
ip_usuario=`echo $IP_FACE | cut -d'-' -f1`
nome_usuario=`echo $IP_FACE | cut -d'-' -f2`
iptables -I FORWARD -d $ip_usuario -m string --algo bm --string "facebook.com" -j REJECT
iptables -I FORWARD -s $ip_usuario -m string --algo bm --string "facebook.com" -j REJECT
iptables -I OUTPUT -d $ip_usuario -m string --algo bm --string "facebook.com" -j REJECT
iptables -I OUTPUT -s $ip_usuario -m string --algo bm --string "facebook.com" -j REJECT
done
for IP_ORKUT in `cat /etc/bloqueio_orkut`
do
ip_usuario=`echo $IP_ORKUT | cut -d'-' -f1`
nome_usuario=`echo $IP_ORKUT | cut -d'-' -f2`
iptables -I FORWARD -d $ip_usuario -m string --algo bm --string "orkut.com" -j REJECT
iptables -I FORWARD -s $ip_usuario -m string --algo bm --string "orkut.com" -j REJECT
iptables -I OUTPUT -d $ip_usuario -m string --algo bm --string "orkut.com" -j REJECT
iptables -I OUTPUT -s $ip_usuario -m string --algo bm --string "orkut.com" -j REJECT
done
echo "Ativando Diretivas de Bloqueios a Sites Específicos...... [OK]"
# Bloqueia acesso HTTP via WAN
$ipt -A INPUT -i em1 -p tcp --dport $http -j DROP
echo "Ativando bloqueio porta HTTP via WAN..................... [OK]"
### Manter conexões estabelecidas para não parar
$ipt -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A FORWARD -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
echo "Mantendo Conexões Prévias Ativas......................... [OK]"
### Configura a Proteção anti-spoofing
for spoofing in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo "1" > $spoofing
done
echo "Ativando Proteção Anti-Spoofing.......................... [OK]"
### Configura Proteção Anti-Redirecionamento de Rotas
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo "Ativando Proteção Anti-Redirecionamento de Rotas......... [OK]"
### Configura Proteção Responses Bogus
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo "Ativando Proteção Anti-Bogus Response.................... [OK]"
### Configura Proteção Anti-SynFlood
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo "Ativando a Proteção Anti-SynFlood........................ [OK]"
### Configura Proteção Contra PortScan Ocultos
$ipt -N SCANNER
$ipt -A SCANNER -j DROP
$ipt -A INPUT -i $lan -p tcp --tcp-flags ALL FIN,URG,PSH -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "FIN,URG,PSH"
$ipt -A INPUT -i $wan -p tcp --tcp-flags ALL FIN,URG,PSH -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "FIN,URG,PSH"
$ipt -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags ALL NONE -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "NULL Packets"
$ipt -A INPUT -i $wan -p tcp --tcp-flags ALL NONE -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "NULL Packets"
$ipt -A INPUT -p tcp --tcp-flags ALL NONE -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags ALL NONE -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags ALL ALL -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL Packets"
$ipt -A INPUT -i $wan -p tcp --tcp-flags ALL ALL -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL Packets"
$ipt -A INPUT -p tcp --tcp-flags ALL ALL -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags ALL ALL -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags ALL FIN,SYN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL FIN,SYN"
$ipt -A INPUT -i $wan -p tcp --tcp-flags ALL FIN,SYN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL FIN,SYN"
$ipt -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "SYN,RST"
$ipt -A INPUT -i $wan -p tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "SYN,RST"
$ipt -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "XMAS Packets"
$ipt -A INPUT -i $wan -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "XMAS Packets"
$ipt -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags FIN,ACK FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "FIN Packets Scan"
$ipt -A INPUT -i $wan -p tcp --tcp-flags FIN,ACK FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "FIN Packets Scan"
$ipt -A INPUT -p tcp --tcp-flags FIN,ACK FIN -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags FIN,ACK FIN -i $wan -j SCANNER
$ipt -A INPUT -i $lan -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL SYN,RST,ACK,FIN,URG"
$ipt -A INPUT -i $wan -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "ALL SYN,RST,ACK,FIN,URG"
$ipt -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $lan -j SCANNER
$ipt -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $wan -j SCANNER
echo "Ativando Proteção contra PortScans....................... [OK]"
### Tentativa de bloqueio de P2P
# Torrent
$ipt -N LOGDROP > /dev/null 2> /dev/null
$ipt -F LOGDROP
$ipt -A LOGDROP -j LOG --log-prefix "LOGDROP "
$ipt -A LOGDROP -j DROP
$ipt -t nat -A PREROUTING -i $wan -p tcp --dport 6881:6889 -j DNAT --to-dest 10.3.1.8
$ipt -A FORWARD -p tcp -i $wan --dport 6881:6889 -d 10.3.1.8 -j REJECT
$ipt -A FORWARD -m string --algo bm --string "BitTorrent" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "peer_id=" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string ".torrent" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "torrent" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "announce" -j LOGDROP
$ipt -A FORWARD -m string --algo bm --string "info_hash" -j LOGDROP
# iMash
$ipt -A FORWARD -d 216.35.208.0/24 -j DROP
# BearShare
$ipt -A FORWARD -p tcp --dport 6346 -j DROP
# ToadNode
$ipt -A FORWARD -p tcp --dport 6346 -j DROP
# WinMX
$ipt -A FORWARD -d 209.61.186.0/24 -j DROP
$ipt -A FORWARD -d 64.49.201.0/24 -j DROP
# Napigator
$ipt -A FORWARD -d 209.25.178.0/24 -j DROP
# Morpheus
$ipt -A FORWARD -d 206.142.53.0/24 -j DROP
$ipt -A FORWARD -p tcp --dport 1214 -j DROP
# KaZaA
$ipt -A FORWARD -d 213.248.112.0/24 -j DROP
$ipt -A FORWARD -p tcp --dport 1214 -j DROP
# Limewire
$ipt -A FORWARD -p tcp --dport 6346 -j DROP
# Audiogalaxy
$ipt -A FORWARD -d 64.245.58.0/23 -j DROP
echo "Ativando Tentativa de Bloqueio P2P....................... [OK]"
### Bloqueia TraceRoute
$ipt -A INPUT -p udp -s 0/0 -i $lan --dport 33435:33525 -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Trace Route"
$ipt -A INPUT -p udp -s 0/0 -i $wan --dport 33435:33525 -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Trace Route"
$ipt -A INPUT -p udp -s 0/0 -i $lan --dport 33435:33525 -j DROP
$ipt -A INPUT -p udp -s 0/0 -i $wan --dport 33435:33525 -j DROP
$ipt -A FORWARD -p udp -s 0/0 -i $lan --dport 33435:33525 -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Trace Route"
$ipt -A FORWARD -p udp -s 0/0 -i $wan --dport 33435:33525 -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Trace Route"
$ipt -A FORWARD -p udp -s 0/0 -i $lan --dport 33435:33525 -j DROP
$ipt -A FORWARD -p udp -s 0/0 -i $wan --dport 33435:33525 -j DROP
echo "Ativando Bloqueio TraceRoute............................. [OK]"
### Bloqueia Ataques DoS
$ipt -A INPUT -m state --state INVALID -j DROP
$ipt -A FORWARD -m state --state INVALID -j DROP
$ipt -A OUTPUT -p tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
echo "Ativando Bloqueio Contra Ataques DoS..................... [OK]"
### Proteção Contra Ping da Morte
$ipt -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
$ipt -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
$ipt -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 1/s -j DROP
$ipt -A FORWARD -p icmp --icmp-type echo-reply -m limit --limit 1/s -j DROP
echo "Ativando Proteção Contra Ping da Morte................... [OK]"
### Proteção Contra Syn
$ipt -A INPUT -i $lan -p tcp ! --syn -m state --state NEW -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Drop Syn"
$ipt -A INPUT -i $lan -p tcp ! --syn -m state --state NEW -j DROP
$ipt -A INPUT -i $wan -p tcp ! --syn -m state --state NEW -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Drop Syn"
$ipt -A INPUT -i $wan -p tcp ! --syn -m state --state NEW -j DROP
echo "Ativando a Proteção Anti-Syn............................. [OK]"
### Proteção Contra Fragmentos
$ipt -A INPUT -i $lan -f -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Fragments Packets"
$ipt -A INPUT -i $lan -f -j DROP
echo "Ativando a Proteção Contra Fragmentos.................... [OK]"
# Aceita pacotes icmp do ip 200.XXX.XXX.XXX (Nagios)
$ipt -A INPUT -s 200.XXX.XXX.XXX/31 -p icmp -j ACCEPT
$ipt -A INPUT -s 200.XXX.XXX.XXX/31 -p tcp --dport 5666 -j ACCEPT
$ipt -A INPUT -s 200.XXX.XXX.XXX/31 -p udp --dport 5666 -j ACCEPT
# Aceita pacotes icmp do ip 201.XXX.XXX.XXX (Nagios)
$ipt -A INPUT -s 201.XXX.XXX.XXX/31 -p icmp -j ACCEPT
$ipt -A INPUT -s 201.XXX.XXX.XXX/31 -p tcp --dport 5666 -j ACCEPT
$ipt -A INPUT -s 201.XXX.XXX.XXX/31 -p udp --dport 5666 -j ACCEPT
# Aceita pacotes icmp da rede 10.X.X.X (Rede Interna e Rede Setor XXXX)
$ipt -A INPUT -s 10.0.0.0/8 -p icmp -j ACCEPT
$ipt -A INPUT -s 10.0.0.0/8 -p tcp --dport 5666 -j ACCEPT
$ipt -A INPUT -s 10.0.0.0/8 -p udp --dport 5666 -j ACCEPT
# Aceita Conexões para o SSH apenas pela rede interna (porta 2222)
$ipt -A INPUT -i $lan -p tcp --dport $ssh -j ACCEPT
$ipt -A INPUT -i $wan -p tcp --dport $ssh -j DROP
# Aceita Conexões para o Squid pela rede interna (porta 3128)
$ipt -A INPUT -i $lan -p tcp --dport $squid -j ACCEPT
$ipt -A INPUT -i $wan -p tcp --dport $squid -j DROP
echo "Configurando regras de INPUT............................. [OK]"
# Regras para roteamento interno domínio yyyy.xxxx.com.br
$ipt -A FORWARD -d yyyy.xxxx.com.br -j ACCEPT
### Ativação do Mascaramento IP
$ipt -t nat -F POSTROUTING
$ipt -t nat -A POSTROUTING -o $wan -j MASQUERADE
echo "Ativando o Mascaramento IP............................... [OK]"
# Liberação sites internos
$ipt -A FORWARD -s 10.0.0.0/8 -j ACCEPT
$ipt -A INPUT -s 10.0.0.0/8 -j ACCEPT
$ipt -A OUTPUT -s 10.0.0.0/8 -j ACCEPT
### Redireciona HTTP para Squid
$ipt -t nat -A PREROUTING -i $lan -p tcp --dport $http -j REDIRECT --to-port $squid
$ipt -A INPUT -p tcp --dport $squid ! -s 10.X.X.X/31 -j DROP
### Liberação e Redirecionamento de Portas Específicas (Marcio / Alex)
$ipt -A INPUT -p tcp --destination-port 44444 -j ACCEPT
$ipt -A INPUT -p tcp --destination-port 55555 -j ACCEPT
$ipt -A INPUT -p udp --destination-port 44444 -j ACCEPT
$ipt -A INPUT -p udp --destination-port 55555 -j ACCEPT
$ipt -A INPUT -i $wan -p tcp -s 0/0 --sport 44444 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A INPUT -i $wan -p tcp -s 0/0 --sport 55555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A INPUT -i $wan -p udp -s 0/0 --sport 44444 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A INPUT -i $wan -p udp -s 0/0 --sport 55555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -t nat -A PREROUTING -i $wan -p tcp --dport 44444 -j DNAT --to-dest 10.X.X.11
$ipt -t nat -A PREROUTING -i $wan -p tcp --dport 55555 -j DNAT --to-dest 10.X.X.10
$ipt -t nat -A PREROUTING -i $wan -p udp --dport 44444 -j DNAT --to-dest 10.X.X.11
$ipt -t nat -A PREROUTING -i $wan -p udp --dport 55555 -j DNAT --to-dest 10.X.X.10
$ipt -A FORWARD -p tcp -i $wan --dport 44444 -d 10.X.X.11 -j ACCEPT
$ipt -A FORWARD -p tcp -i $wan --dport 55555 -d 10.X.X.10 -j ACCEPT
$ipt -A FORWARD -p udp -i $wan --dport 44444 -d 10.X.X.11 -j ACCEPT
$ipt -A FORWARD -p udp -i $wan --dport 55555 -d 10.X.X.10 -j ACCEPT
echo "Liberando Portas Específicas............................. [OK]"
### Porta 8834 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $nessus -j ACCEPT
### Porta 2222 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $ssh -j ACCEPT
$ipt -A FORWARD -i $wan -p tcp --dport $ssh -j DROP
### Porta 3128 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $squid -j ACCEPT
### Porta 53 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p udp --dport $dns -j ACCEPT
### Porta 110 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $pop -j ACCEPT
### Porta 25 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $smtp -j ACCEPT
### Porta 587 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $smtp2 -j ACCEPT
### Porta 80 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $http -j ACCEPT
### Porta 443 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $https -j ACCEPT
### Porta 21 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $ftp -j ACCEPT
### Porta 143 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $imap -j ACCEPT
### Porta 44444 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $marcio -j ACCEPT
### Porta 55555 - Aceita para Rede Local
$ipt -A FORWARD -i $lan -p tcp --dport $alex -j ACCEPT
### Compartilhamento de Rede DataCenter SETOR B
$ipt -A FORWARD -s 10.0.0.0/8 -p tcp -j ACCEPT
$ipt -A FORWARD -s 10.0.0.0/8 -p udp -j ACCEPT
### Log de Bloqueio Padrão
$ipt -A FORWARD -m limit --limit 2/m -j LOG --log-prefix "FORWARD: Bloqueio Padrao "
$ipt -A FORWARD -j DROP
### Habilita tráfego IP entre as interfaces de rede
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Habilitando Tráfego IP Entre as Interfaces de Rede....... [OK]"
### Bloqueia tudo o que não tenha sido anteriormente declarado como regra
$ipt -A INPUT -p tcp --syn -j DROP
echo "Aplicando Regra de Bloqueio Geral de Pacotes............. [OK]"
echo " "
echo "************** FIREWALL CONFIGURADO COM SUCESSO **************"
echo
}
firewall_restart() {
firewall_stop
firewall_start
}
firewall_stop() {
clear
echo "=============================================================="
echo ":: DESATIVANDO O FIREWALL ::"
echo "=============================================================="
# Define o local do binário do iptables
ipt="/sbin/iptables"
# Interfaces
wan=em1
lan=eth0
### Retorna aao padrão das cadeias
$ipt -P INPUT ACCEPT
$ipt -P FORWARD ACCEPT
$ipt -P OUTPUT ACCEPT
### Limpa as Regras de Firewall
$ipt -Z
$ipt -F INPUT
$ipt -F OUTPUT
$ipt -F FORWARD
$ipt -F SCANNER
$ipt -F LOGDROP
$ipt -t nat -F
$ipt -t mangle -F
for spoofing in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo "0" > $spoofing
done
echo 1 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 0 > /proc/sys/net/ipv4/tcp_syncookies
echo "Limpando Todas as Regras................................. [OK]"
### Reativação do Mascaramento IP
$ipt -t nat -F POSTROUTING
$ipt -t nat -A POSTROUTING -o $wan -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
}
case "$1" in
'start')
firewall_start
;;
'stop')
firewall_stop
;;
'restart')
firewall_restart
;;
*)
firewall_start
esac
http_port 10.X.X.X:3128 transparent
retry_on_error off
cache_mem 2048 MB
maximum_object_size_in_memory 128 KB
maximum_object_size 512 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
httpd_suppress_version_string on
refresh_pattern ^ftp: 15 20% 2280
refresh_pattern ^gopher: 15 0% 2280
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 15 20% 2280
memory_pools off
quick_abort_max 16 KB
quick_abort_pct 95
quick_abort_min 16 KB
reply_header_max_size 20 KB
acl tudo src all
acl b99 src 10.X.99.0/24
acl b100 src 10.X.100.0/24
acl b101 src 10.X.101.0/24
acl b102 src 10.X.102.0/24
acl b103 src 10.X.103.0/24
acl b104 src 10.X.104.0/24
acl b105 src 10.X.105.0/24
acl b106 src 10.X.106.0/24
acl b107 src 10.X.107.0/24
acl b108 src 10.X.108.0/24
acl b109 src 10.X.109.0/24
acl b110 src 10.X.110.0/24
acl b111 src 10.X.111.0/24
acl b112 src 10.X.112.0/24
acl b113 src 10.X.113.0/24
acl b114 src 10.X.114.0/24
acl b115 src 10.X.115.0/24
acl b116 src 10.X.116.0/24
acl SSL_ports port 443 563
acl Safe_ports port 143 #imap http
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 1863 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 59
acl Safe_ports port 901
acl Safe_ports port 1000
acl purge method PURGE
acl CONNECT method CONNECT
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow b99
http_access allow b100
http_access allow b101
http_access allow b102
http_access allow b103
http_access allow b104
http_access allow b105
http_access allow b106
http_access allow b107
http_access allow b108
http_access allow b109
http_access allow b110
http_access allow b111
http_access allow b112
http_access allow b113
http_access allow b114
http_access allow b115
http_access allow b116
http_access deny tudo