Página 1 de 2 12 ÚltimoÚltimo
+ Responder ao Tópico



  1. Bom pessoal quanto tempo! Estive bem ocupado nesses últimos mesês e continuo ocupado. Mais como eu tinha prometido eu vou traduzir a regras de firewall e explicar o que eu entendo sobre elas.


    Bom, eu vou logo dizendo que as configurações são de autoria de outra pessoa.
    Segue o link abaixo

    Dmitry on firewalling - MikroTik Wiki
    • Classificação de protocolos
    • Filtro de pacotes invalidos
    • detecto port-scanners
    • Policiameto
    • Filtro de protocolos de aplicativos
    • Filtros epecificos em TCP
    • Filtros específicos para protocolos de certos aplicativos

    Introdução

    Tem que ter duas placas de redes conectadas a o roteador MIKROTIK,
    1 eth0= Public que é a mesma que fica conectada na internet.
    2 Eth1=local que fica na rede local ( clientes ).


    Agora vamos conhecer e marcar todos os protocolos de rede para você pode identificar o que mais trafega na sua rede e assim poder estabelecer regras de QOS.

    Ele vai criar algumas regras no mangle, com pular conexões pré-roteadas tais como TCP, UDP e novas conexões
    / ip firewall mangle
    add chain=prerouting protocol=tcp connection-state=new action=jump jump-target=tcp-services
    add chain=prerouting protocol=udp connection-state=new action=jump jump-target=udp-services
    add chain=prerouting connection-state=new action=jump jump-target=other-services



    Agora ele vai marcar as conexões de todos os protocolos de aplicativos, o tipo de serviço, destino de suas conexoes e suas respectivas portas. Na mesma foto acima da para ver os protocolos de certos aplicativos marcados. Note que ele marca praticamente todos os serviços básicos de aplicativos tipo (Emule VNC, Https, PPTP entre outros).

    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=20-21 action=mark-connection new-connection-mark=ftp passthrough=no
    add chain=tcp-services protocol=tcp src-port=513-65535 dst-port=22 action=mark-connection new-connection-mark=ssh passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=23 action=mark-connection new-connection-mark=telnet passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=25 action=mark-connection new-connection-mark=smtp passthrough=no
    add chain=tcp-services protocol=tcp src-port=53 dst-port=53 action=mark-connection new-connection-mark=dns passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=53 action=mark-connection new-connection-mark=dns passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=80 action=mark-connection new-connection-mark=http passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=110 action=mark-connection new-connection-mark=pop3 passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=113 action=mark-connection new-connection-mark=auth passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=119 action=mark-connection new-connection-mark=nntp passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=143 action=mark-connection new-connection-mark=imap passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=161-162 action=mark-connection new-connection-mark=snmp passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=443 action=mark-connection new-connection-mark=https passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=465 action=mark-connection new-connection-mark=smtps passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=993 action=mark-connection new-connection-mark=imaps passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=995 action=mark-connection new-connection-mark=pop3s passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=1723 action=mark-connection new-connection-mark=pptp passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=2379 action=mark-connection new-connection-mark=kgs passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=3128 action=mark-connection new-connection-mark=proxy passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=3389 action=mark-connection new-connection-mark=win-ts passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=4242-4243 action=mark-connection new-connection-mark=emule passthrough=no
    add chain=tcp-services protocol=tcp src-port=4661-4662 dst-port=1024-65535 action=mark-connection new-connection-mark=overnet passthrough=no
    add chain=tcp-services protocol=tcp src-port=4711 dst-port=1024-65535 action=mark-connection new-connection-mark=emule passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=5900-5901 action=mark-connection new-connection-mark=vnc passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=6667-6669 action=mark-connection new-connection-mark=irc passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=6881-6889 action=mark-connection new-connection-mark=bittorrent passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=8080 action=mark-connection new-connection-mark=http passthrough=no
    add chain=tcp-services protocol=tcp src-port=1024-65535 dst-port=8291 action=mark-connection new-connection-mark=winbox passthrough=no
    add chain=tcp-services protocol=tcp action=mark-connection new-connection-mark=other-tcp passthrough=no


    add chain=other-services protocol=icmp icmp-options=8:0-255 action=mark-connection new-connection-mark=ping passthrough=no
    add chain=other-services protocol=gre action=mark-connection new-connection-mark=gre passthrough=no
    add chain=other-services action=mark-connection new-connection-mark=other passthrough=no



    Agora vamos ao que ele chama de Sanity-check

    Pacotes genéricos inválidos e técnicas de detecção de port-scanners.

    /ip firewall mangle
    add chain=prerouting in-interface=Public dst-address-list=nat-addr action=mark-packet new-packet-mark=nat-traversal passthrough=no

    Esse ai de cima você vai colocar antes de todas as outras regras de mangle.
    Miniaturas de Anexos Miniaturas de Anexos Clique na imagem para uma versão maior

Nome:	         mangle especificos de protocolos.GIF
Visualizações:	208
Tamanho: 	89,6 KB
ID:      	1084  
    Última edição por balisteri; 03-09-2007 às 22:34.

  2. Agora como acima alguns filtros adicionados a lista de acesso, a mesma lista que deve ser acrescentadas de outros endereços.


    / ip firewall address-list
    add list=illegal-addr address=0.0.0.0/8 comment="illegal addresses"
    add list=illegal-addr address=127.0.0.0/8
    add list=illegal-addr address=224.0.0.0/3
    add list=illegal-addr address=10.0.0.0/8
    add list=illegal-addr address=172.16.0.0/12
    add list=illegal-addr address=192.168.0.0/16
    add list=local-addr address=172.31.255.0/29 comment="my local network"
    add list=nat-addr address=172.31.255.0/29 comment="my local network"


    Então agora temos três tipos de lista de acesso:

    1 lista de endereços ilegais
    Essa lista pode ser extendida por você basta verificar os endereços ilegais na IANA IANA Home Page existem muito mais, mas só que no momento somente alguns exemplos.
    2 lista dos endereços locais
    Esses são os endereços de sua redes a que fica atrás do firewall.
    3 lista dos endereços do NAT
    E neste ultimo os endereços que você faz o NAT


    No próximo você exclui as conexões de clientes em portas diferentes na sua interface local. Há ia esquecendo as conexões de ponte também.
    / ip firewall filter
    add chain=forward in-interface=Local out-interface=Local action=accept comment="Allow traffic between wired and wireless networks"


    Bom, já filtramos tudo e marcamos todos os pacotes. Agora vamos criar algumas chains para logar e deixar todas as informações em um único lugar

    / ip firewall filter
    add chain=forward action=jump jump-target=sanity-check comment="Sanity Check"
    add chain=sanity-check packet-mark=nat-traversal action=jump jump-target=drop comment="Deny illegal NAT traversal"
    add chain=sanity-check protocol=tcp psd=20,3s,3,1 action=add-src-to-address-list address-list=blocked-addr address-list-timeout=1d comment="Block port scans"
    add chain=sanity-check protocol=tcp tcp-flags=fin,psh,urg,!syn,!rst,!ack action=add-src-to-address-list address-list=blocked-addr address-list-timeout=1d comment="Block TCP Null scan"
    add chain=sanity-check protocol=tcp tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg action=add-src-to-address-list address-list=blocked-addr address-list-timeout=1d comment="Block TCP Xmas scan"
    add chain=sanity-check protocol=tcp src-address-list=blocked-addr action=jump jump-target=drop
    add chain=sanity-check protocol=tcp tcp-flags=rst action=jump jump-target=drop comment="Drop TCP RST"
    add chain=sanity-check protocol=tcp tcp-flags=fin,syn action=jump jump-target=drop comment="Drop TCP SYN+FIN"
    add chain=sanity-check connection-state=invalid action=jump jump-target=drop comment="Dropping invalid connections at once"
    add chain=sanity-check connection-state=established action=accept comment="Accepting already established connections"
    add chain=sanity-check connection-state=related action=accept comment="Also accepting related connections"
    add chain=sanity-check dst-address-type=broadcast,multicast action=jump jump-target=drop comment="Drop all traffic that goes to multicast or broadcast addresses"
    add chain=sanity-check in-interface=Local dst-address-list=illegal-addr dst-address-type=!local action=jump jump-target=drop comment="Drop illegal destination addresses"
    add chain=sanity-check in-interface=Local src-address-list=!local-addr action=jump jump-target=drop comment="Drop everything that goes from local interface but not from local address"
    add chain=sanity-check in-interface=Public src-address-list=illegal-addr action=jump jump-target=drop comment="Drop illegal source addresses"
    add chain=sanity-check in-interface=Public dst-address-list=!local-addr action=jump jump-target=drop comment="Drop everything that goes from public interface but not to local address"
    add chain=sanity-check src-address-type=broadcast,multicast action=jump jump-target=drop comment="Drop all traffic that goes from multicast or broadcast addresses"

    Filtros específicos de alguns aplicativos.

    / ip firewall filter
    add chain=forward protocol=tcp action=jump jump-target=restrict-tcp
    add chain=forward protocol=udp action=jump jump-target=restrict-udp
    add chain=forward action=jump jump-target=restrict-ip
    add chain=restrict-tcp connection-mark=auth action=reject
    add chain=restrict-tcp connection-mark=smtp action=jump jump-target=smtp-first-drop comment="anti-spam policy"
    add chain=smtp-first-drop src-address-list=first-smtp action=add-src-to-address-list address-list=approved-smtp
    add chain=smtp-first-drop src-address-list=approved-smtp action=return
    add chain=smtp-first-drop action=add-src-to-address-list address-list=first-smtp
    add chain=smtp-first-drop action=reject reject-with=icmp-network-unreachable



    Restringindo servicos.

    / ip firewall filter
    add chain=restrict-tcp connection-mark=other-tcp action=jump jump-target=drop
    add chain=restrict-udp connection-mark=other-udp action=jump jump-target=drop
    add chain=restrict-ip connection-mark=other action=jump jump-target=drop


    Protegendo o roteador

    É nessa hora que a mulekada chora, hehehee.


    / ip firewall filter
    add chain=input src-address-type=local dst-address-type=local action=accept comment="Allow local traffic \(between router applications\)"
    add chain=input in-interface=Local protocol=udp src-port=68 dst-port=67 action=jump jump-target=dhcp comment="DHCP protocol would not pass sanity checking, so enabling it explicitly before other checks"
    add chain=input action=jump jump-target=sanity-check comment="Sanity Check"
    add chain=input dst-address-type=!local action=jump jump-target=drop comment="Dropping packets not destined to the router itself, including all broadcast traffic"
    add chain=input in-interface=Local action=jump jump-target=local-services comment="Allowing some services to be accessible from the local network"
    add chain=input in-interface=Public action=jump jump-target=public-services comment="Allowing some services to be accessible from the Internet"
    add chain=input connection-mark=ping limit=5,5 action=accept comment="Allow pings, but at a very limited rate \(5 per sec\)"
    add chain=input action=jump jump-target=drop
    add chain=dhcp src-address=0.0.0.0 dst-address=255.255.255.255 action=accept
    add chain=dhcp src-address=0.0.0.0 dst-address-type=local action=accept
    add chain=dhcp src-address-list=local-addr dst-address-type=local action=accept
    add chain=local-services connection-mark=ssh action=accept comment="SSH \(22/TCP\)"
    add chain=local-services connection-mark=dns action=accept comment="DNS"
    add chain=local-services connection-mark=proxy action=accept comment="HTTP Proxy \(3128/TCP\)"
    add chain=local-services connection-mark=winbox comment="Winbox \(8291/TCP\)" disabled=no
    add chain=local-services action=drop comment="Drop Other Local Services"
    add chain=public-services connection-mark=ssh action=accept comment="SSH \(22/TCP\)"
    add chain=public-services connection-mark=pptp action=accept comment="PPTP \(1723/TCP\)"
    add chain=public-services connection-mark=gre action=accept comment="GRE for PPTP"
    add chain=public-services action=drop comment="Drop Other Public Services"

    Jogando tudo para o proxy

    / ip firewall nat
    add chain=dstnat in-interface=Local connection-mark=dns action=redirect comment="proxy for DNS requests"
    add chain=dstnat in-interface=Local connection-mark=http protocol=tcp action=redirect to-ports=3128 comment="proxy for HTTP requests"
    add chain=dstnat in-interface=Local connection-mark=ntp action=redirect comment="proxy for NTP requests"







    E agora habilitando o servidores proxy

    / system ntp server
    set enabled=yes broadcast=no multicast=no manycast=no
    / system ntp client
    set enabled=yes mode=unicast primary-ntp=xxx.xxx.xxx.xxx secondary-ntp=0.0.0.0
    / ip proxy
    set enabled=yes port=3128 parent-proxy=0.0.0.0:1 maximal-client-connections=1000 maximal-server-connections=1000
    / ip dns
    set primary-dns=yyy.yyy.yyy.yyy secondary-dns=0.0.0.0 allow-remote-requests=yes cache-size=2048KiB cache-max-ttl=1w



  3. Olá amigo, blz? desculpe as perguntas, sou leigo no MK, mas essas regras falando básicamente, para q servem? São usadas na mesma máquina q está o mikrotik ou num serv separado entre o servidor mk e os clientes? Valeuuu

  4. Eu usei esse passo-a-passo direto do wiki do mikrotik e tive uma queda de desempenho na minha rede, acho que esse firewall funciona bem com poucos usuários, pois quando estava em uma parte da minha rede funcionava beleza depois que coloquei 400 clientes em cima a cisa ficou lerda demais.

    Estou desenvolvendo um firewall poderoso me baseando por esse e por outros e testando passo a passo, acho que daqui pro final eu publico esse guia.



  5. pois é aqui no meu caso eu tenho em meus servers uns 150 em cada eu uso essa regra nele mesmo e não tenho problema de lentidão






Tópicos Similares

  1. Estou de volta a ativa!!!
    Por marcelloduarte no fórum Assuntos não relacionados
    Respostas: 3
    Último Post: 25-05-2005, 10:42
  2. Como eu faço para fazer um redirecionamento de porta ?
    Por Redirecionamento de porta no fórum Servidores de Rede
    Respostas: 7
    Último Post: 20-03-2005, 07:08
  3. como eu coloco o caracter de interrogaçao
    Por ldeftones no fórum Servidores de Rede
    Respostas: 14
    Último Post: 21-02-2005, 09:29
  4. como eu coloco um papel de parede no fluxbox
    Por ldeftones no fórum Servidores de Rede
    Respostas: 5
    Último Post: 14-02-2005, 18:49
  5. postfix não envia e nem recebe e-mail acima de 10MB, como eu
    Por Leyzem no fórum Servidores de Rede
    Respostas: 4
    Último Post: 16-03-2003, 11:51

Visite: BR-Linux ·  VivaOLinux ·  Dicas-L