MikroTik
How to Configure Mangle Rules on MikroTik: Step by Step
As Mangle Rules (Regras de Mangle) no Mikrotik são usadas para marcar pacotes ou conexões, permitindo gerenciar tráfego de rede de forma avançada. Essas regras são essenciais para balanceamento de carga, QoS (Quality of Service) e controle granular do tráfego.
Step-by-Step Guide to Configuring Mangle Rules on MikroTik
1. Access the MikroTik
- Conecte-se ao dispositivo via WinBox, SSH, ou interface Web.
2. Configure Connection Marking
- Adicione uma regra para marcar conexões específicas. Por exemplo, marque conexões HTTP:
RouterOS
/ip firewall mangle add chain=prerouting protocol=tcp dst-port=80 action=mark-connection new-connection-mark=HTTP_conn passthrough=yes
3. Configure Packet Marking
- Marque os pacotes pertencentes às conexões marcadas anteriormente:
RouterOS
/ip firewall mangle add chain=prerouting connection-mark=HTTP_conn action=mark-packet new-packet-mark=HTTP_packet passthrough=yes
4. Apply Bandwidth Control with the Created Marks
- Use as marcas para gerenciar largura de banda. Por exemplo, limite o tráfego HTTP a 5 Mbps:
RouterOS
/queue tree add name=HTTP_queue parent=global packet-mark=HTTP_packet max-limit=5M
5. Configure Load Balancing with Mangle Rules (optional)
- Marque conexões para diferentes links WAN para balancear o tráfego:
RouterOS
/ip firewall mangle add chain=prerouting dst-address-type=!local per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes /ip firewall mangle add chain=prerouting dst-address-type=!local per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
6. Monitor the Mangle Rules
- Acompanhe as estatísticas para verificar se as regras estão sendo aplicadas corretamente:
RouterOS
/ip firewall mangle print stats
7. Adjust Rule Order (if necessary)
- Certifique-se de que as regras de Mangle estão na ordem correta para evitar conflitos:
RouterOS
/ip firewall mangle move 0
8. Test the Configuration
- Generate HTTP or other marked traffic and monitor whether it is being handled according to the defined rules.