I have found a way to limit upload/download speed for specific domains using Mikrotik. I will demonstrate the steps I performed to achieve that.
What’s technically going to happen is:
1- Collect all IP addresses for the given domain name (such as youtube.com)
2- Identify the connections that are active to that domain.
3- Mark the packets for those connections.
4- Queue those packets and limit their speed.
First, we need to create a firewall filter rule. Go to IP, Firewall to create one.
- Chain: forward
- Protocol: tcp
- Content: youtube.com
- Destination Port: 80,443
- Action: Add dst to address list
- address list: youtube-auto
Now go to Mangle and create:
- Chain: forward
- Dst Address List: youtube-auto
- Action: Mark connection
- Connection Mark: youtube-connections
- Passthrough: true
Now create another rule with:
- Chain: forward
- Connection mark: youtube-connections
- Action: Mark packet
- Packet Mark: youtube-packets
- Passthrough: false
Finally, for traffic shaping:
Go to Queues and create a new queue:
General:
Target Upload/Download Max Limit: 128k (or any value)
Advanced:
Packet Mark: youtube-packets
Now when you open youtube.com, you’ll realize that the queue is being used, and the maximum speed is around the set value.