I have setup Bandwidth Based Dual WAN Routing based on the script given here [ http://mum.mikrotik.com/presentations/US12/tomas.pdf ]. Its working perfectly fine.
Now I want to route youtube.com over WAN2 always since its a cheaper connection. So far I have been able to get a script and scheduler to check for YouTube.com DNS and add it to the Firewall Address list. Now I can't figure out what Firewall Mangle rule to write so that I can redirect youtube to wan2. Any help, pointers will be appreciated. Thanks.
SSV = WAN1
TATA = WAN2
Please find the export of my Firewall Rules below
Code: Select all
/ip firewall address-list
add address=192.168.2.0/24 list=Conected
add address=192.168.1.0/24 list=Conected
add address=192.168.3.0/24 list=Conected
add address=192.168.3.0/24 list=LAN
add address=216.58.199.142 comment=youtube.com list=youtube
add address=216.58.199.164 comment=googlevideo.com list=youtube
add address=1.186.190.211 comment=r8.sn-q8vpn-cvhz.googlevideo.com list=\
youtube
add address=209.85.227.12 comment=r7.sn-q4f7snek.googlevideo.com list=youtube
add address=1.186.190.208 comment=r5.sn-q8vpn-cvhz.googlevideo.com list=\
youtube
add address=1.186.191.77 comment=r2.sn-q8vpn-cvhs.googlevideo.com list=\
youtube
add address=173.194.6.142 comment=r9.sn-4g57knes.googlevideo.com list=youtube
add address=173.194.24.234 comment=r4.sn-q4fl6ner.googlevideo.com list=\
youtube
add address=1.186.191.79 comment=r4.sn-q8vpn-cvhs.googlevideo.com list=\
youtube
add address=1.186.190.205 comment=r2.sn-q8vpn-cvhz.googlevideo.com list=\
youtube
add address=1.186.190.210 comment=r7.sn-q8vpn-cvhz.googlevideo.com list=\
youtube
add address=173.194.9.201 comment=r4.sn-25g7sne7.googlevideo.com list=youtube
add address=1.186.191.140 comment=r1.sn-q8vpn-cvhl.googlevideo.com list=\
youtube
add address=173.194.132.136 comment=r3.sn-p5qlsnle.googlevideo.com list=\
youtube
add address=1.186.190.204 comment=r1.sn-q8vpn-cvhz.googlevideo.com list=\
youtube
add address=173.194.135.54 comment=r17.sn-aigllnse.googlevideo.com list=\
youtube
add address=173.194.151.74 comment=r4.sn-4g5e6nes.googlevideo.com list=\
youtube
/ip firewall filter
add action=accept chain=input protocol=icmp
add action=accept chain=input connection-state=established in-interface=SSV \
log-prefix="ssv icmp"
add action=accept chain=input connection-state=established in-interface=TATA \
log-prefix="TATA icmp"
add action=accept chain=input connection-state=new dst-port=500 in-interface=\
SSV log=yes protocol=udp
add action=accept chain=input connection-state=new dst-port=1701 \
in-interface=SSV log=yes protocol=udp
add action=accept chain=input connection-state=new dst-port=4500 \
in-interface=SSV log=yes protocol=udp
/ip firewall mangle
add action=mark-routing chain=prerouting comment="youtube mangle" \
connection-mark=no-mark dst-address-list=youtube in-interface=bridge1 \
log=yes new-routing-mark=TATA_Route passthrough=no protocol=tcp
add action=accept chain=prerouting dst-address-list=Connected \
src-address-list=Connected
add chain=input connection-mark=no-mark in-interface=SSV
add action=mark-connection chain=input connection-mark=no-mark in-interface=\
SSV new-connection-mark=WAN1->ROS
add action=mark-connection chain=input connection-mark=no-mark in-interface=\
TATA new-connection-mark=WAN2->ROS
add action=mark-routing chain=output connection-mark=WAN1->ROS \
new-routing-mark=SSV_Route
add action=mark-routing chain=output connection-mark=WAN2->ROS \
new-routing-mark=TATA_Route
add action=mark-connection chain=forward connection-mark=no-mark \
in-interface=SSV new-connection-mark=WAN1->LANs
add action=mark-connection chain=forward connection-mark=no-mark \
in-interface=TATA new-connection-mark=WAN2->LANs
add action=mark-routing chain=prerouting connection-mark=WAN1->LANs \
new-routing-mark=SSV_Route src-address-list=LAN
add action=mark-routing chain=prerouting connection-mark=WAN2->LANs \
new-routing-mark=TATA_Route src-address-list=LAN
add action=mark-connection chain=prerouting connection-mark=no-mark \
dst-address-list=!Connected dst-address-type=!local new-connection-mark=\
LAN->WAN src-address-list=LAN
add action=mark-routing chain=prerouting comment="Load balancing" \
connection-mark=LAN->WAN new-routing-mark=SSV_Route src-address-list=LAN
add action=mark-connection chain=prerouting connection-mark=LAN->WAN \
new-connection-mark=Sticky_SSV routing-mark=SSV_Route
add action=mark-connection chain=prerouting connection-mark=LAN->WAN \
new-connection-mark=Sticky_TATA routing-mark=TATA_Route
add action=mark-routing chain=prerouting connection-mark=Sticky_SSV \
new-routing-mark=SSV_Route src-address-list=lan
add action=mark-routing chain=prerouting connection-mark=Sticky_TATA \
new-routing-mark=TATA_Route src-address-list=Lan
add action=mark-routing chain=prerouting connection-mark=Sticky_SSV \
new-routing-mark=SSV_Route src-address-list=Lan
/ip firewall nat
add action=masquerade chain=srcnat out-interface=SSV
add action=masquerade chain=srcnat out-interface=TATA