Kamis, 14 Maret 2013

Mikrotik Youtube Routing To Other Wan (Interface)



Mikrotik Youtube Routing To Other Wan (Interface)


route youtube mikrotik
In this tutorial we route youtube.com to other dedicated wan link.
We need to classify the traffic through ROUTE MARKING.
There are following 4 simple steps
Step # 1 “Script”
Lot of people want to do something with connections to Google and YouTube, but they change IP addresses so often and make problems to track. One of the solutions is to dinamically update address lists on your Mikrotik router.
This script create Prefect youtube address-list
Mikrotik Script
:foreach i in=[/ip dns cache find] do={
    :local bNew "true";
    :local cacheName [/ip dns cache all get $i name] ;
#    :put $cacheName;

    :if ([:find $cacheName "youtube"] != 0) do={

        :local tmpAddress [/ip dns cache get $i address] ;
# :put $tmpAddress;

# if address list is empty do not check
        :if ( [/ip firewall address-list find ] = "") do={
            :log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
            /ip firewall address-list add address=$tmpAddress list=youtube_dns_ips comment=$cacheName;
        } else={
            :foreach j in=[/ip firewall address-list find ] do={
                :if ( [/ip firewall address-list get $j address] = $tmpAddress ) do={
                    :set bNew "false";
                }
            }
            :if ( $bNew = "true" ) do={
                :log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
                /ip firewall address-list add address=$tmpAddress list=youtube_dns_ips comment=$cacheName;
            }
        }
    }
}
Step # 2 “Scheduler”
Create a Schedule to update the address-list
Mikrotik Scheduler
/system scheduler add name=youtube start-time=startup interval=0
0:00:20 on-event="/system script run youtube-script"
Mikrotik address list
Step # 3 “Firewall Mangle”
Now we mark route for youtube
Mikrotik Firewall
/ip firewall mangle add chain=prerouting protocol=tcp dst-port=80 
dst-address-list=youtube_dns_ips action=mark-routing 
new-routing-mark=youtube_route passthrough=yes
Step # 4 “Route”
Now Add Route For youtube.

Mikrotik route
/ip route add comment=”Youtube Route Traffic admsln.team@gmail.com" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=197.1.1.2 routing-mark=youtube_route scope=255 target-scope=10

Tidak ada komentar:

Posting Komentar