Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

NC

In this article, I will show you how to redirect traffic to the 2nd WAN with the Mikrotik router. On the router I have a basic configuration with 2 WANs with WAN 1 as the primary and WAN2 as the backup.

Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

Here is the article : Easiest way to configure load balancing on Mikrotik router

I will do YouTube traffic redirection and you can do the same with FacebookTiktok and other social networks.

Name to LAN IP block

Go to "IP" > "Firewall" > "Address Lists"

To do that you need to get the list of IP addresses of YouTube servers automatically.

First you will name your IP Lan block, in this video I named it "LAN-IP", my local network address is 192.168.1.0/24.

Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

Next step I will create a raw rule.

Create Raw Rule

Go to "IP" > "Firewall" >"Raw", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List [!]: LAN-IP, Content : ".youtube.com", Action : add dst to address list, Address List : "YouTube-IP", Comment : "YouTube-IP".

Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

Go to "IP" > "Firewall" >"Raw", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List [!]: LAN-IP, Content : ".googlevideo.com", Action : add dst to address list, Address List : "YouTube-IP".

Go to "IP" > "Firewall" >"Raw", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List [!]: LAN-IP, Content : ".ytimg.com", Action : add dst to address list, Address List : "YouTube-IP".

Go to "IP" > "Firewall" >"Raw", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List [!]: LAN-IP, Content : ".youtu.be", Action : add dst to address list, Address List : "YouTube-IP".

Go to "IP" > "Firewall" >"Raw", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List [!]: LAN-IP, Content : ".youtube.googleapis.com", Action : add dst to address list, Address List : "YouTube-IP".

This is essentially how to get the ip address of the YouTube servers and memorize it on the Mikrotik router. This list will be automatically updated, you only need to configure it once. I named the list of ip servers of YouTube "YouTube-IP".

To do that, you need a list like the one above. I put the list here:

Facebook: 

.facebook.com

.facebook.net 

.fbcdn.net

.fbsbx.com

fb.com

fb.gg

fbwat.ch

messenger.com

m.me


Instagram:

.instagram.com

.cdninstagram.com


Twitter:

twitter.com

.twitter.com

.twimg.com

t.co


Tiktok:

.tiktok.com

.tiktokv.com

.tiktokcdn.com

.byteoversea.com

.ibyteimg.com

.ibytedtos.com

.myqcloud.com


Youtube:

.youtube.com

.googlevideo.com

.ytimg.com

.youtu.be

.youtube.googleapis.com

Every time someone accesses YouTube the server IP address will be stored here. This list will be automatically updated.

Create Mangle Rule

Based on the list of ip addresses of the YouTube server in the previous step, I will redirect the traffic to WAN2. We will Mark the YouTube traffic, we route those packets through WAN2. After configuring everyone using YouTube will be completely redirected to WAN2.

Go to "IP" > "Firewall" > "Mangle", Chain : prerouting, Src.Address List : LAN-IP, Dst.Address List : "YouTube-IP", Action : mark routing, New Routing Mark : WAN2_Route.

Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

Route Configuration

Go to "IP" > "Route", Gateway : "pppoe out2" (WAN2), Routing Mark : WAN2_Route.

Redirect traffic to the 2nd WAN on Mikrotik router ( YouTube, Facebook, Tiktok )

For other social networks you do the same as above.

Facebook: https://www.facebook.com/routerbest

Twitter: https://twitter.com/routerbestcom

Tags: Tiktok Facebook YouTube Mikrotik