sexta-feira, 21 de outubro de 2011

Cache full no Mikrotik / Cache full in Mikrotik

Neste tutorial, você vai aprender a configurar um cache full em seu servidor Mikrotik de forma que todos os arquivos e programas baixado na internet pela sua rede interna fique armazenado no seu servidor, assim, quando outro usuário quiser baixar esse mesmo arquivo, ele não irá consumir mais banda, vai pegar esse arquivos direto do seu servidor na velocidade da sua rede interna. Para isso você vai precisa dos seguintes pré-requisitos:
In this tutorial you will learn how to configure a cache full Mikrotik on your server so that all files and programs downloaded from the Internet by your internal network be stored on your server, so when another user wants to download that same file, it will not consume more bandwidth, this will pick up files directly from your server at the speed of your internal network. For this you will need the following prerequisites:
  1. Ter o proxy devidamente configurado em seu servidor. Se ainda não tem, veja como fazer nesse link
  2. Ter um HD grande para poder armazenar todos os downloads.
  1. Having the proxy properly configured on your server. If you have not already, check out howthis link
  2. Having a large hard disk so you can store all downloads.
Vamos começar!
Let's get started!

1. Primeiro vamos realizar as marcações de conexões e pacotes no mangle. Clique em IP depois em FIREWALL
1. First we perform the markings of connections and packets in the mangle. Click IP thenFIREWALL


2. Na aba MANGLE, clique no botão +. Na aba GENERAL, no campo CHAIN selecione a opção OUTPUT. No campo PROTOCOL, selecione a opção TCP. No campo SRC.PORT, coloque a porta de configuração do seu proxy, se você não alterou, então coloque a porta 8080. Agora na aba ADVANCED, no campo DSCP (TOS), coloque 4 (esse é o número do Tipo de Serviço utilizado pelo proxy). Agora clique na aba ACTION, no campo ACTION, selecione a opção MARK CONNECTION. No campo NEW MARK CONNECTION coloque CONN-CACHE-FULL e deixe a opção PASSTHROUGH marcado. Por fim, clique em OK.
2. Mangle tab, click the + button. On the General tab, select the field CHAIN ​​OUTPUT option. In the Protocol field, select TCP. SRC.PORT in the field, put the port configuration of your proxy if you have not changed, then put the port 8080. Now on the Advanced tab, in the field DSCP (TOS), 4th place (this is the number of the type used by service proxy). Nowclick on the tab ACTION, ACTION field, select MARK CONNECTION. In the field NEWCONN-MARK place CONNECTION CACHE-FULL and leave the option PASSTHROUGHmarked. Finally, click OK.




3. Vamos para a próxima regra. Clique no botão + novamente. Na aba GENERAL, no campo CHAIN, selecione a opção OUTPUT. No campo CONNECTION MARK, selecione a opção CONN-CACHE-FULL. Agora na aba ACTION, no campo ACTION, selecione a opção MARK PACKET e no campo NEW PACKET MARK, coloque PAC-CACHE-FULL. Deixe marcada a opção PASSTHROUGH. Depois clique em OK.
3. Let's go to the next rule. Click the + button again. On the General tab, in the field CHAIN,select the OUTPUT option. MARK CONNECTION In the field, select the CONN-CACHE-FULL. Now tab ACTION, ACTION field, select the field and MARK PACKET PACKETNEW MARK, place PAC-CACHE-FULL. Check the box PASSTHROUGH. Then click OK.



4. Agora a última regra do mangle. Clique novamente no botão +. Na aba GENERAL, no campo CHAIN, selecione a opção OUTPUT. No campo CONNECTION MARK, selecione CONN-CACHE-FULL. Agora clique na aba ACTION e no campo ACTION selecione RETURN. Essa regra faz com que, depois de ter marcado as conexões do proxy, todas as suas regras do mangle (caso você tenha mais regras) continuem funcionando perfeitamente.
4. Now the last rule in the mangle. Click the + button again. On the General tab, in the fieldCHAIN, select the OUTPUT option. MARK CONNECTION In the field, selectCONN-CACHE-FULL. Now click on the tab in the field ACTION ACTION and selectRETURN. This rule means that, after you have checked the connections to the proxy, all the rules of the mangle (if you have more rules) continue to function perfectly.

Depois de ter feito essas três regras, lembre de colocá-las como as três primeiras regras do mangle arrastando-as pra cima.
Once you have done these three rules, remember to place them as the first three rules of the mangle dragging them up.



Agora vamos criar um regra em FILTER pra por permitir que sua rede interna tenha acesso ao proxy.
Now let's create a rule for allowing FILTER to your internal network has access to the proxy.

5. Ainda em IP > FIREWALL, clique na aba FILTER e depois no botão +. Na aba GENERAL, no campo CHAIN, selecione a opção INPUT. No campor PROTOCOL, selecione a opção TCP, no campo DST.PORT coloque a porta do seu proxy 8080, no campo IN.INTERFACE, selecione a placa de rede da sua rede interna. Agora clique na aba ACTION. No campo ACTION, selecione a opção ACCEPT.
5. Although IP-> Firewall, click the FILTER tab and then the + button. On the General tab, in the field CHAIN​​, select INPUT. In camporee PROTOCOL, select TCP in the fieldDST.PORT put your proxy port 8080, IN.INTERFACE field, select the network card of your internal network. Now click on the tab ACTION. In the Action field, select ACCEPT.



Pronto. O proxy está devidamente funcionando. Para testar, faça um download em algum site de um programa ou arquivo em alguma máquina interna sua. Depois, baixe esse MESMO arquivo ou programa de outra máquina da rede interna e observe a velocidade desse segundo download.
Pronto. The proxy is properly working. To test, download from a site of a program or filesomewhere inside your machine. Then download the same file or program to another machine on the internal network and observe the speed of this second download.

27 comentários:

  1. ROGERIO OBRIGADO PELAS DICAS EU FIZ AQUI SO Q TO NA DUVIDA POIS TEM COISAS AQUI Q NAO ESTAO ESCRITAS IGUAIS AS IMAGENS MAIS VLW MSM SE DER CERTO VAI ME AJUDAR MUITO BRIGADAO AMIGO

    ResponderExcluir
  2. Rogerio. Muito bem explicadissimo. Parabens. Anotei seu mail farei contato pelo MSN.

    ResponderExcluir
  3. exelente, eu um leigo, consegui fazer o proposto neste site sem dificuldades... gostaria de saber se os sites ficam em cache tambem, ou so os programas baixados é que ficam ?
    obrigado por este site e pela ajuda

    ResponderExcluir
  4. Amigo, os sites também ficam em cache. só STREAM (youtube, vídeos..etc) não ficam em cache.
    Fico feliz em ter ajudado.

    ResponderExcluir
  5. Rogério...Teria como redirecionar o webproxy de uma RB433 para uma máquina com algum sistema instalado e com HD para cache,ou teria que ser um MK/PC?

    ResponderExcluir
    Respostas
    1. Também gostaria de saber isso

      Excluir
    2. Amigo, para armazenar conteúdo em cache, tem que ser no MK versão PC. Nas routerboard não dá, pois, as mesmas não têm "hd" para armazenar tal conteúdo.

      Excluir
  6. Parabéns pelo tutorial, me ajudou muito, gostaria que postasse algum tutorial para fazer cache do youtube!
    vlw!

    ResponderExcluir
  7. Amigo valeu mesmo esse tutorial me ajudou muito.
    Vou testar pra ver se funciona.

    ResponderExcluir
  8. Amigo gostei do cache, mais sou novo na area e gostaria de saber como fazer o cache no mesmo mikrotik usando o hotspot?

    ResponderExcluir
  9. Rogério aqui é Rostand gostei da sua explicação teria como vc entrar em contato comigo pelo whatsapp (82) 96629725

    ResponderExcluir
  10. Amigo só estou com uma duvida... Eu não vou precisar de uma segunda maquina com nenhum tipo de programa como thuder cache para receber os arquivos? Ou posso usar a própria cpu que esta o mikrotik para receber e reenviar?

    ResponderExcluir
  11. Parabens cara! Muito boa explicaçao! Que Deus te abencoe grandemente.

    ResponderExcluir
  12. Parabens cara! Muito boa explicaçao! Que Deus te abencoe grandemente.

    ResponderExcluir
  13. bom dia rogerio tudo bem , sou meio leigo em mk , quem faz as minhas configuraçoes é um colega meu mais ele viajou e ficou dificil de me ajudar, tenho 2 redes em 2 mk rb1100ahx2 q sao alimentados por um load balance mk rb1100 q tem 8 links , quero saber como posso fazer esse cache , tenho q comprar outra mk rb1100? ou tenho q ter um pc para servir como servidor ? ou um mk separado resolve isso? tenho interrese em fazer esse cache mais nao sei como

    ResponderExcluir
  14. Esse cache se faz no load balance é?

    ResponderExcluir
  15. como adiciono local que vai salvar os links? ( HD, ou PC ). fiz tudo como descrito mas parece não funcionar.

    ResponderExcluir
  16. Ok, cache de vídeos nao funciona no caso de streaming correto, mas se o vídeo tiver a opção download ele armazena, corretos?

    ResponderExcluir
  17. Oi amigo gostei muito da sua explicação. Poderia entrar em contato comigo pelo zap 94991064354

    ResponderExcluir
  18. amigo bom dia, tem como limitar o tamanho do programas a ser armazenado em cache ?obigado

    ResponderExcluir