+ Responder ao Tópico



  1. #1
    capgaiotto
    Visitante

    Padrão Fazer funcionar Proxy Transparente

    Olá Pessoal!

    Lendo os inúmeros artigos, tutoriais e posts existentes aqui no Underlinux, cheguei a conclusão que é extremamente fácil configurar o squid para funcionar transparente.
    Configurei meu script de firewall com a seguinte regra de roteamento:


    ifconfig eth1 192.168.10.253
    echo 1 > /proc/sys/net/ipv4/ip_forward
    /sbin/modprobe ip_tables
    /sbin/modprobe ip_conntrack
    /sbin/modprobe iptable_nat
    /sbin/modprobe ip_nat_ftp
    #PROXY TRANSPARENTE
    /usr/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
    #NAT
    /usr/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    /usr/sbin/iptables -A FORWARD -o eth0 -j ACCEPT



    E em seguida cofigurei o SQUID.CONF


    visible_hostname proxymc
    http_port 3128
    hierarchy_stoplist cgi-bin ?
    cache_mem 64 MB
    cache_swap_low 90
    cache_swap_high 95
    maximum_object_size 10000 KB
    minimum_object_size 0 KB
    maximum_object_size_in_memory 8 KB
    cache_dir ufs /var/cache/squid 100 16 256
    cache_access_log /var/log/squid/access.log
    cache_log /var/log/squid/cache.log
    cache_store_log /var/log/squid/store.log
    pid_filename /var/run/squid.pid
    refresh_pattern ^ftp: 1440 20% 10080
    refresh_pattern ^gopher: 1440 0% 1440
    refresh_pattern . 0 20% 4320
    acl proibir_sites url_regex "/etc/sites_proibidos"
    acl all src 0.0.0.0/0.0.0.0
    acl manager proto cache_object
    acl rede src 192.168.0.0
    acl localhost src 127.0.0.1 255.255.255.255
    acl to_localhost dst 127.0.0.1 8
    acl SSL_ports port 443 563
    acl Safe_ports port 80 # http
    acl Safe_ports port 21 # ftp
    acl Safe_ports port 443 563 # https, snews
    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 # multing http
    acl CONNETC method CONNECT
    http_access deny proibir_sites
    http_access allow rede
    http_access allow all manager localhost
    http_reply_access allow all
    #PROXY TRANSPARENTE
    httpd_accel_host virtual
    httpd_accel_port 80
    httpd_accel_with_proxy on
    httpd_accel_uses_host_header on
    coredump_dir /var/cache/squid


    A única coisa que defini nas estações de trabalho foi o IP do Servidor como GATEWAY.
    As estações continuam navegando, mas NÃO estão passando pelo Proxy.
    Marcando o IP + Porta no browser da estação do usuário, funciona ok, inclusive a ACL que criei para bloquear sites.
    O proxy transparente não está funcionando.

    Muito Obrigado!

    Gaiotto

  2. #2
    kr4mus
    Visitante

    Padrão Re: Fazer funcionar Proxy Transparente

    Bom dia!

    Pelos servers que instalei até hoje posso de afirmar mas não de explicar:
    Algumas regras funcionam em uns e em outros não.

    Tente o seguinte:
    #iptables -t nat -A PREROUTING -p tcp --dport 80 -s $REDEINTERNA \
    -d ! $REDEDAOUTRA_INTERFACE -j REDIRECT --to-ports 3128

    Valew,
    Marcus Burghardt

  3. #3

    Padrão Re: Fazer funcionar Proxy Transparente

    Retira essa regra, e faça o teste:

    /usr/sbin/iptables -A FORWARD -o eth0 -j ACCEPT

  4. #4
    capgaiotto
    Visitante

    Padrão Re: Fazer funcionar Proxy Transparente

    Olá caros amigos!

    Consegui resolver o problema.
    Na regra:
    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

    ETH0 refere-se a placa de rede da rede interna, como no meu server a rede interna esta como eth1, bastou alterar esse parametro na regra de roteamento!
    Ficando:

    iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128


    Obrigado pela ajuda!!

    Gaiotto