# #####the open exchange queue that is outside other queues # ##streaming video inside the 10mb queue /queue tree add max-limit=10M name=in parent=global add max-limit=10M name=out parent=global add name=oix-in packet-mark=oix-in parent=global queue=default add name=oix-out packet-mark=oix-out parent=global queue=default add limit-at=4M max-limit=10M name=streaming-video-in packet-mark=streaming-video-in parent=in priority=3 \ queue=default add limit-at=4M max-limit=10M name=streaming-video-out packet-mark=streaming-video-out parent=out \ priority=3 queue=default # setting up this local router's BGP instance - don't use outside of lab /routing bgp instance set default as=65100 # our mangle rules to mark OIX connections, then packets /ip firewall mangle add action=mark-connection chain=prerouting comment="oix con mark" \ dst-address-list=RCoix new-connection-mark=oix add action=mark-packet chain=prerouting comment="oix-in packet mark" \ connection-mark=oix in-interface=gre-oix new-packet-mark=oix-in \ passthrough=no add action=mark-packet chain=prerouting comment="oix-out packet mark" \ connection-mark=oix new-packet-mark=oix-out passthrough=no # our mangle rules to mark streaming video based on address lists # ######streaming mark for twitch add action=mark-connection chain=prerouting comment=\ "streaming video connection mark BGP" dst-address-list=RCstreamingvideo \ new-connection-mark=streaming-video protocol=tcp src-address-list=\ internal-nets add action=mark-connection chain=prerouting comment=\ "streaming video connection mark L7" connection-mark=no-mark dst-port=80 \ layer7-protocol=video new-connection-mark=streaming-video protocol=tcp \ src-address-list=internal-nets add action=mark-packet chain=prerouting comment=\ "streaming video in packet mark" connection-mark=streaming-video \ in-interface=ether3 new-packet-mark=streaming-video-in passthrough=no add action=mark-packet chain=prerouting comment=\ "streaming video out packet mark" connection-mark=streaming-video \ new-packet-mark=streaming-video-out passthrough=no #setting up our peers - particularly our route filters /routing bgp peer add in-filter=bgp-qos-in name=peer-ISP out-filter=bgp-out remote-address=\ x.x.x.x remote-as=x ttl=default add in-filter=bgp-qos-in name=peer-OIX out-filter=bgp-out remote-address=\ 172.17.1.2 remote-as=65101 ttl=default #configure our route filters for twitch, vudu, and our open IX /routing filter add bgp-as-path="^.*,46489\$" chain=bgp-qos-in comment=Twitch \ set-route-comment=RCstreamingvideo add bgp-as-path="^.*,40582\$" chain=bgp-qos-in comment=Vudu set-route-comment=\ RCstreamingvideo add bgp-communities=65101:10 chain=bgp-qos-in comment="OIX set LP 110" \ set-bgp-local-pref=110 set-route-comment=RCoix add chain=bgp-qos-in comment="*clear all*" disabled=yes set-route-comment="" # schedule our script /system scheduler add interval=1d name=bgp-qos on-event=bgp-qos policy=\ ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=\ apr/22/2015 start-time=04:00:00 # create the script /system script add name=bgp-qos policy=\ ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":log info\ \_\"BGP QoS script start\";\r\ \n#Define Local Var and load data\r\ \n#loop variables\r\ \n:local i 0;\r\ \n#route ip address\r\ \n:local ipAddress;\r\ \n#is it marked for us\r\ \n:local routeMark \"null\";\r\ \n#route comment\r\ \n:local routeComment \"null\";\r\ \n#check the beginning of our routeComment\r\ \n:local listName \"null\";\r\ \n\r\ \n#loop to check the entire routing table\r\ \n:foreach i in=[/ip rou find] do={\r\ \n #grab the route's comment\r\ \n :set routeComment [/ip route get \$i comment]\r\ \n #check if to make sure the route comment isn't null\r\ \n :if (\$routeComment!=\"\") do={\r\ \n #grab the first two letters off of the route comment\r\ \n set listName [:pick \$routeComment 0 2]\r\ \n #make sure the first two letters are RC\r\ \n :if (\$listName=\"RC\") do={\r\ \n #get the IP address of the route\r\ \n :set ipAddress [/ip route get \$i dst-address]\r\ \n #log debug info to the log\r\ \n# :log info \"\$i - \$routeSize - \$routeMark - \$routeComment - \$li\ stName - \$ipAddress\";\r\ \n #if it is the default gateway don't add it, otherwise add it to th\ e addresslist for 23 hours and 30 seconds\r\ \n :if (\$ipAddress!=0.0.0.0/0) do={\r\ \n /ip firewall address-list rem [find where list=\$routeComment ad\ dress=\$ipAddress];\r\ \n /ip firewall address-list add list=\$routeComment address=\$ipAd\ dress timeout=88200;}\r\ \n }\r\ \n }\r\ \n}\r\ \n:log info \"BGP QoS script complete\";"