MikroTik
How to Configure Mangle Rules on MikroTik: Step by Step
VPS 8GB RAM + 75GB NVMe — R$59/mês4 vCPUs · Tráfego ilimitado · Ubuntu Server LTS · Suporte para instalação incluso
Contratar agoraStep-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.