1) We can't throttle Youtube by name, but we can throttle the IP. First, we set up a script to resolve hostnames and put them in an address list:
Code: Select all
# define variables
:local list
:local hosts
:local newip
# Loop through each entry in the address list.
:foreach i in=[/ip firewall address-list find] do={
# Get the first four characters of list name
:set list [:pick [/ip firewall address-list get $i list] 0 4]
# Condition: if the value of $list is "dns_" process it.
:if ($list = "dns_") do={
# Of the items being processed, store their "comment" fields as the variable "hosts"
:set hosts [/ip firewall address-list get $i comment]
# Resolve it and set the address list entry accordingly.
:set newip [:resolve $hosts]
/ip firewall address-list set $i address=$newip
}
}
2) Now we make the list and put an entry in it for Youtube. The way that script works is that you just put the FQDN in the comment field of the list entry, and script does dns lookups based on that.
Code: Select all
/ip firewall address-list add address=0.0.0.0 comment=youtube.com list=dns_choke
3) The next step is to make some firewall rules to mark all packets with .flv or .mp4 content coming from the IP we have in the address list:
Code: Select all
/ip firewall mangle add chain=forward protocol=tcp src-address-list=dns_choke content=.flv action=mark-packet new-packet-mark=choked_video comment="Mark .flv content from address list for queuing"
/ip firewall mangle add chain=forward protocol=tcp src-address-list=dns_choke content=.mp4 action=mark-packet new-packet-mark=choked_video comment="Mark .mp4 content from address list for queuing"
Code: Select all
/queue simple add name="Youtube Video Content" max-limit=64k/64k packet-marks=choked_video
...of course. Youtube uses load distribution through DNS (such as the round-robin technique.) Since the IP could be any of a number of servers, the computers resolving on the LAN side aren't likely to hit the same IP that's in the address list, so the packets aren't being processed.
Anyone know a way to accomplish what I'm attempting here?