MikroTik Certified Routing Engineer (MTCRE)
1 Introduction to MikroTik RouterOS
2 RouterOS Basics
1 Installation and Initial Configuration
2 User Management
3 System Resources
4 Backup and Restore
3 Interfaces and Bridges
1 Interface Configuration
2 Bridge Configuration
3 VLAN Configuration
4 Routing
1 Static Routing
2 Dynamic Routing Protocols
1 OSPF
2 BGP
3 EIGRP
3 Policy-Based Routing
5 Firewall and Security
1 Firewall Basics
2 NAT Configuration
3 IPsec VPN
4 SSL VPN
5 Traffic Shaping
6 Wireless Networking
1 Wireless Interface Configuration
2 Wireless Security
3 Wireless Bridging
4 Wireless Client Mode
7 QoS and Traffic Management
1 Queue Types
2 Queue Trees
3 Priority Queues
4 Traffic Rules
8 Load Balancing and High Availability
1 Load Balancing
2 High Availability with VRRP
3 Failover Configuration
9 Monitoring and Diagnostics
1 System Logs
2 Traffic Monitoring
3 Diagnostic Tools
10 Advanced Topics
1 IPv6 Configuration
2 MPLS Configuration
3 SDN and Automation
4 Cloud Hosted Router
11 Practical Scenarios
1 Small OfficeHome Office (SOHO) Network
2 Enterprise Network
3 Service Provider Network
12 Certification Exam Preparation
1 Exam Format and Structure
2 Practice Questions
3 Hands-On Labs
3 Policy-Based Routing in MikroTik

3 Policy-Based Routing in MikroTik

1. Understanding Policy-Based Routing

Policy-Based Routing (PBR) allows you to route traffic based on specific criteria such as source IP address, destination IP address, or application type. This method provides granular control over traffic flow, enabling advanced network management and optimization.

2. Key Concepts

There are three primary concepts to understand when configuring Policy-Based Routing in MikroTik:

a. Routing Rules

Routing rules define the conditions under which traffic should be routed differently. These conditions can include source IP, destination IP, protocol, and port number. For example, you can create a rule to route all traffic from a specific IP range through a different gateway.

b. Routing Tables

Routing tables store the routes that traffic will take based on the defined rules. You can create multiple routing tables and assign different routes to each. For instance, you might have a default routing table for general traffic and a separate table for traffic from a specific department.

c. Routing Policies

Routing policies combine routing rules and routing tables to determine the final path for traffic. Policies are evaluated in a specific order, and the first matching policy will dictate the route. This allows for complex routing decisions based on multiple criteria.

3. Practical Examples

Let's walk through a practical example of configuring Policy-Based Routing in MikroTik:

Example 1: Routing Traffic from a Specific IP Range

  1. Create a Routing Table: /routing table add name=SpecialRoutes
  2. Add a Route to the New Table: /ip route add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-table=SpecialRoutes
  3. Create a Routing Rule: /ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=SpecialRoutes src-address=192.168.1.10/32

In this example, traffic from the IP address 192.168.1.10 will be routed through the gateway 192.168.2.1 using the SpecialRoutes routing table.

Example 2: Prioritizing VoIP Traffic

  1. Create a Routing Table for VoIP: /routing table add name=VoIPRoutes
  2. Add a Route for VoIP: /ip route add dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-table=VoIPRoutes
  3. Create a Routing Rule for VoIP: /ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=VoIPRoutes protocol=udp dst-port=5060

In this example, all VoIP traffic (UDP port 5060) will be routed through the gateway 192.168.3.1 using the VoIPRoutes routing table, ensuring it gets prioritized.

4. Insightful Value

Policy-Based Routing in MikroTik offers unparalleled flexibility and control over network traffic. By mastering this concept, you can create sophisticated routing policies that optimize performance, enhance security, and ensure efficient use of network resources. This knowledge is essential for anyone aiming to become a MikroTik Certified Routing Engineer.