Enviado em 12/05/2016 - 22:06h
Boa noite amigos, depois de varias tentativas resolvi procurar ajuda... Sou iniciante em iptables e proxy. Estou tento o seguinte problema:
#!/bin/bash
##############################
###############INICIANDO......
##########VARIAVEIS
# Interface de rede ligada a internet
IFACE_WEB="enp3s0"
# Interface de rede ligada a rede interna
IFACE_REDE="enp2s0"
# Rede interna
REDE_INTERNA="192.168.10.0/24"
# Portas liberadas TCP
PORTAS_TCP="20,21,53,80,443"
# Portas liberadas UDP
PORTAS_UDP="53"
# Portas liberadas para a rede interna
PORTAS_REDE_INTERNA="25,110"
##########LIMPAR REGRAS
# Limpa as regras da tabela filter
iptables -F
# Limpa as regras da tabela nat
iptables -t nat -F
##########POLITICA PADRAO
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
##########REPASSE
echo 1 > /proc/sys/net/ipv4/ip_forward
############
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
##########NAT
# COMPARTILHA A INTERNET #
iptables -t nat -A POSTROUTING -s $REDE_INTERNA -o $IFACE_WEB -j MASQUERADE
##########INPUT
#Proxy
iptables -A INPUT -p tcp -i enp2s0 --dport 3128 -j ACCEPT
# Libera o acesso SSH de qualquer origem
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Libera DNS
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
# Libera HTTPS
#iptables -A FORWARD -p tcp --dport 443 -j ACCEPT #----> Dessa forma a funciona, mas fica vulneravel.
# Aceita ping apenas da rede interna
iptables -A INPUT -s $REDE_INTERNA -p icmp --icmp-type 8 -j ACCEPT
##########FORWARD
#Pertas internas
iptables -A FORWARD -p tcp -m multiport --dports $PORTAS_REDE_INTERNA -j ACCEPT
##########FIM
#########SQUID 3.3.8
#
##############################
###############INICIANDO......
##########Mensagens de erro em Português
error_directory /usr/share/squid/errors/pt-br
##########Porta do Squid
http_port 3128
##########Nome do servidor
visible_hostname SERVIDOR01
##########Cache
cache_mem 700 MB
maximum_object_size_in_memory 32 KB
maximum_object_size 1024 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /etc/squid/cache 30000 16 256
##########Logs de acesso
access_log /var/log/squid/access.log squid
##########Regras acl padrão
acl todos src 192.168.10.0/24
#acl manager proto cache_object #------> SE ATIVAR ESSA LINHA, DA ERRO NA HORA DE INICIAR O SQUID.
acl local src 127.0.0.1/32
acl SSL_ports port 443 563 873
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 873 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
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 901 # swat
acl Safe_ports port 1025-65535 # portas altas
acl purge method PURGE
acl CONNECT method CONNECT
##########ALLOW / DENY
# Permissões e bloqueios padrão
#http_access allow manager local
#http_access deny manager
http_access allow purge local
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
# Bloqueio de sites por URL
acl sites_proibidos url_regex -i "/etc/squid/sites_proibidos"
http_access deny sites_proibidos
# Bloqueio de downloads por extensão
acl downloads_proibidos url_regex -i \.exe \.torrent \.avi \.mp3
http_access deny downloads_proibidos
# Permissão rede local e servidor
acl redelocal src 192.168.10.0/24
http_access allow local
http_access allow redelocal
# Bloqueio de usuários fora da rede
http_access deny todos
##########FIM