Enviado em 08/06/2017 - 09:58h
Desculpa as pressa em responder vc e testar as coisas.root@proxy:/etc/squid3# cat squid.conf
# Squid normally listens to port 3128
http_port 3128 intercept
visible_hostname proxy.controler
#dns_nameservers 201.6.2.124 #208.67.222.222 #DNS do OPENDNS
#dns_nameservers 208.67.220.220 #DNS do OPENDNS
maximum_object_size 16 MB
cache_dir ufs /var/spool/squid3 2048 16 256
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid3
#always_direct allow all
#never_direct allow none
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
#acl all src 0.0.0.0/0.0.0.0
#acl localnet src 192.168.0.0/24
#acl SSL_ports port 443
#acl Safe_ports port 80 # http
#acl Safe_ports port 21 # ftp
#acl Safe_ports port 443 # 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 CONNECT method CONNECT
##ACLS
acl proibidos url_regex -i "/etc/squid3/sites_proibidos"
acl permitidos url_regex -i "/etc/squid3/sites_permitidos"
acl FullAccess src 192.168.0.49
acl redelocal src 192.168.0.0/24
#http_access allow localhost manager localnet
#http_access deny manager
#http_access deny !Safe_ports
#http_access deny CONNECT !SSL_ports
acl SSL_ports port 443 563
acl Safe_ports port 2095 # webmail
acl Safe_ports port 25 # smtp
acl Safe_ports port 587 # smtp
acl Safe_ports port 110 # pop
acl Safe_ports port 80 # http
acl Port_8080 port 8080 # prefeitura
acl Port_809 port 809 # SPtrans
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # 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 37777 # intelbras portatil
acl Safe_ports port 7070 # intepbras http
acl Safe_ports port 8081 #grv
acl Safe_ports port 2021 # intepbras http
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow Port_8080
http_access allow Port_809
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !Safe_ports
http_access allow localhost
##Controle de acesso
http_access allow redelocal
http_access allow FullAccess
http_access allow permitidos
http_access deny proibidos
http_access allow localhost
http_access allow all
root@proxy:/var/log/squid3# tail -f access.log
1496926538.273 0 192.168.0.251 TCP_MISS/403 5114 GET http://www.mercadolivre.com.br/ - HIER_NONE/- text/html
1496926538.273 137 192.168.0.49 TCP_MISS/403 5230 GET http://www.mercadolivre.com.br/ - ORIGINAL_DST/192.168.0.251 text/html
1496926538.298 0 192.168.0.251 TCP_MISS/403 4016 GET http://www.squid-cache.org/Artwork/SN.png - HIER_NONE/- text/html
1496926538.298 15 192.168.0.49 TCP_MISS/403 4132 GET http://www.squid-cache.org/Artwork/SN.png - ORIGINAL_DST/192.168.0.251 text/html
1496926538.306 0 192.168.0.251 TCP_MISS/403 5136 GET http://www.mercadolivre.com.br/favicon.ico - HIER_NONE/- text/html
1496926538.306 1 192.168.0.49 TCP_MISS/403 5252 GET http://www.mercadolivre.com.br/favicon.ico - ORIGINAL_DST/192.168.0.251 text/html
1496926542.470 0 192.168.0.49 TAG_NONE/409 3911 CONNECT www.google.com.br:443 - HIER_NONE/- text/html
1496926543.823 0 192.168.0.251 TCP_MISS/403 4007 GET http://www.squid-cache.org/Artwork/SN.png - HIER_NONE/- text/html
1496926543.823 0 192.168.0.49 TCP_MISS/403 4123 GET http://www.squid-cache.org/Artwork/SN.png - ORIGINAL_DST/192.168.0.251 text/html
### Interfaces de rede
EXT=eth0
INT=eth1
#exemplo de liberar maquina para não passar pelo firewall
#regras
#iptables -t nat -A PREROUTING -s 192.168.X.X -j ACCEPT
#iptables -t nat -A POSTROUTING -s 192.168.X.X -j MASQUERADE
#iptables -t filter -A FORWARD -s 192.168.X.X -j ACCEPT
#iptables -I FORWARD -s 192.168.X.X -j ACCEPT
#iptables -I FORWARD -d 192.168.X.X -j ACCEPT
### INICIO FIREWALL GLOBAL####
### Regras INPUT
### informa os estados que devem ser checados (Conexão estabelecida ou Relacionada). Caso o estado da conexão seja uma dessas 2, então ele vai aceitar.
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT # Libera o INPUT para a interface loopback, ou seja, a própria máquina
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT # Permite icmp 0 (resposta de Echo)
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT # Permite icmp 8 (Pedido de Echo)
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 53 -j ACCEPT #DNS
iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 1194 -j ACCEPT #openvpn - OpenVPN
iptables -A INPUT -p udp -m udp --dport 1194 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 137 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 137 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 3389 -j ACCEPT #conexão remota do windows
iptables -A INPUT -p udp -m udp --sport 3389 -j ACCEPT #conexão remota do windows
iptables -A INPUT -p tcp -m tcp --sport 3389 -j ACCEPT #conexão remota do windows
iptables -A INPUT -p tcp -m tcp --sport 3389 -j ACCEPT #conexão remota do windows
#iptables -A INPUT -p tcp -m tcp --sport 110 -j ACCEPT #pop
#iptables -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
#iptables -A INPUT -p tcp -m tcp --sport 587 -j ACCEPT #smtp
#iptables -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
#iptables -A INPUT -p tcp -s 192.168.11.0/24 --dport 587 -j ACCEPT # SMTP
#iptables -A INPUT -p tcp -s 192.168.11.0/24 --dport 110 -j ACCEPT # SMTP
iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT #http
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 443 -j ACCEPT #ssl
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 22 -j ACCEPT #ssh
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 21 -j ACCEPT #ftp
iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 5900 -j ACCEPT #VNC
iptables -A INPUT -p tcp -m tcp --dport 5900 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 8245 -j ACCEPT #NO-IP
iptables -A INPUT -p tcp -m tcp --dport 8245 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 10050 -j ACCEPT #Zabbix
iptables -A INPUT -p tcp -m tcp --dport 10050 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 8082 -j ACCEPT #us-cli - Utilistor
iptables -A INPUT -p tcp -m tcp --dport 8082 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 21000 -j ACCEPT #irtrans - IRTrans Control
iptables -A INPUT -p tcp -m tcp --dport 21000 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8181 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 8181 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 8080 -j ACCEPT #http-alt - HTTP Alternate
iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 2082 -j ACCEPT #infowave - Infowave Mobility Server
iptables -A INPUT -p tcp -m tcp --dport 2082 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 1194 -j ACCEPT #openvpn - OpenVPN
iptables -A INPUT -p tcp -m tcp --dport 1194 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 137 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 137 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --sport 809 -j ACCEPT #SPTRANS
iptables -A INPUT -p tcp -m tcp --dport 809 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 7531 -j ACCEPT
iptables -A INPUT -p tcp -m multiport -s 0/0 -d 192.168.0.251 --dport 3050,3051 -j ACCEPT #Firebird
iptables -A INPUT -p tcp -m multiport -s 0/0 -d 192.168.0.251 --dport 3000,3001 -j ACCEPT #ntop
#iptables -A INPUT -p tcp -m multiport -s 0/0 -d 192.168.0.48 --dport 1433,1434 -j ACCEPT #SQL
iptables -A INPUT -i $INT -p udp -m udp --sport 135 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --dport 135 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --sport 137 -j ACCEPT #netbios-ns - NETBIOS Name Service
iptables -A INPUT -i $INT -p udp -m udp --dport 137 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --sport 138 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --dport 138 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --sport 139 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --dport 139 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --sport 445 -j ACCEPT
iptables -A INPUT -i $INT -p udp -m udp --dport 445 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --sport 139 -j ACCEPT #netbios-ns - NETBIOS Name Service
iptables -A INPUT -i $INT -p tcp -m tcp --dport 139 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --sport 22000 -j ACCEPT #snapenetio - SNAPenetIO - #alterado para eth1 "verificar se houver erros"
iptables -A INPUT -i $INT -p tcp -m tcp --sport 138 -j ACCEPT #netbios-dgm - NETBIOS Datagram Service
iptables -A INPUT -i $INT -p tcp -m tcp --dport 138 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --sport 135 -j ACCEPT #epmap - DCE endpoint resolution
iptables -A INPUT -i $INT -p tcp -m tcp --dport 135 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --sport 445 -j ACCEPT #microsoft-ds - Microsoft-DS
iptables -A INPUT -i $INT -p tcp -m tcp --dport 445 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --dport 3128 -j ACCEPT #Redirecionaento squid
iptables -A INPUT -i $INT -p tcp -m tcp --dport 3129 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --dport 80 -j ACCEPT #http
iptables -A INPUT -i $INT -p tcp -m tcp --sport 80 -j ACCEPT #http
iptables -A INPUT -i $INT -p tcp -m tcp --sport 81 -j ACCEPT
iptables -A INPUT -i $INT -p tcp -m tcp --dport 81 -j ACCEPT
iptables -A INPUT -i $INT -p icmp -j ACCEPT
iptables -A INPUT -i lo -p udp -m udp --sport 137 -j ACCEPT #netbios-ns - NETBIOS Name Service
iptables -A INPUT -i lo -p udp -m udp --dport 137 -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -p udp -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -p tcp -j ACCEPT
iptables -A INPUT -j DROP
### Regras OUTPUT
#Exemplo bloqueio de saida para internet em alguma maquina
#iptables -A OUTPUT -p tcp -d 192.168.X.X --dport 80 -j DROP
#iptables -A OUTPUT -p tcp -d 192.168.X.X --dport 8080 -j DROP
#iptables -A OUTPUT -p tcp -d 192.168.X.X --dport 443 -j DROP
#iptables -A OUTPUT -p tcp -d 192.168.X.X --dport 53 -j DROP
iptables -P OUTPUT ACCEPT # AUTOEXPLICATIVO
iptables -A OUTPUT -p tcp --dport xmpp-client -j ACCEPT #whatsapp
#iptables -A OUTPUT -p tcp -m multiport -s 0/0 -d 192.168.11.254 --sport 3000,3001 -j ACCEPT #Firebird
#iptables -A OUTPUT -p tcp -m multiport -s 0/0 -d 192.168.11.254 --sport 3050,3051 -j ACCEPT #ntop
#iptables -A OUTPUT -p tcp -m multiport -s 0/0 -d 192.168.11.48 --sport 1433,1434 -j ACCEPT #SQL
### Regras FORWARD
# Contra Ping da Morte
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -j DROP
iptables -A FORWARD -p udp --sport 53 -j ACCEPT #dns
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p udp --sport 123 -j ACCEPT
iptables -A FORWARD -p udp --dport 123 -j ACCEPT
iptables -A FORWARD -p tcp -i $INT -o $EXT --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp -i $INT -o $EXT --dport 587 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 110 -j ACCEPT # POP3
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 587 -j ACCEPT # SMTP
iptables -A FORWARD -p tcp --sport 587 -j ACCEPT #smtp
iptables -A FORWARD -p tcp --dport 587 -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT #pop
iptables -A FORWARD -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp --dport 993 -j ACCEPT #Imap
iptables -A FORWARD -p tcp --sport 993 -j ACCEPT
iptables -A FORWARD -p tcp --dport 995 -j ACCEPT #ssl imap
iptables -A FORWARD -p tcp --sport 993 -j ACCEPT
iptables -A FORWARD -p tcp --sport 443 -j ACCEPT #ssl
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp --sport 123 -j ACCEPT #NTP
iptables -A FORWARD -p tcp --dport 123 -j ACCEPT
iptables -A FORWARD -p tcp --dport 2095 -j ACCEPT #webmail
iptables -A FORWARD -p tcp --sport 8080 -j ACCEPT #http
iptables -A FORWARD -p tcp --dport 8080 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8181 -j ACCEPT
iptables -A FORWARD -p tcp --sport 8181 -j ACCEPT
### Portas DVR Intelbras ###
iptables -A FORWARD -p tcp --dport 37777 -j ACCEPT
iptables -A FORWARD -p tcp --sport 37777 -j ACCEPT
iptables -A FORWARD -p tcp --dport 38888 -j ACCEPT
iptables -A FORWARD -p tcp --sport 38888 -j ACCEPT
iptables -A FORWARD -p tcp --dport 7070 -j ACCEPT
iptables -A FORWARD -p tcp --sport 7070 -j ACCEPT
### Portas conexão area de trabalho remota do Windows
iptables -A FORWARD -p udp -m udp --dport 3389 -j ACCEPT
iptables -A FORWARD -p udp -m udp --sport 3389 -j ACCEPT
iptables -A FORWARD -p tcp -m tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -p tcp -m tcp --sport 3389 -j ACCEPT
#Liberação do Whatsapp para os Celulares
#iptables -A FORWARD -p udp --dport 3478 -j ACCEPT
#iptables -A FORWARD -p udp --dport 3497 -j ACCEPT
#iptables -A FORWARD -p udp --dport 16384 -j ACCEPT
#iptables -A FORWARD -p udp --dport 16387 -j ACCEPT
#iptables -A FORWARD -p udp --dport 16293 -j ACCEPT
#iptables -A FORWARD -p udp --dport 16402 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5222 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5223 -j ACCEPT
iptables -A FORWARD -p tcp --dport 4244 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5228 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5242 -j ACCEPT
iptables -A FORWARD -j DROP
### Regras PREROUTING
#Redirecionamento de porta do Squid
iptables -t nat -A PREROUTING -i $INT -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128