Friday, 24 May 2019

How to block TikTok on a LEDE / OpenWRT Router

TikTok seems to be generating a lot of noise these days especially in India as it was banned in India. It looks like  the ban was temporary and now the app is available again in India. It was just another news for me until I saw that my kids were using this app yesterday. It seems to be a really a dangerous app, with no censor and no rules on the content posted. 

I was worried and thought of blocking this app immediately in my home network. Googled to find the list of URLs used by the TikTok app. No luck. I took help of my OpenWRT Router and logged all the DNS queries passing through it while kids were on the app. Spied :) . 

I saw multiple requests to musical.ly and its sub-domains.  I also saw multiple requests to p16-tiktokcdn-com.akamaized.net.

So to block these domains, the first thing to do is to update /etc/hosts file in OpenWRT with these domains mapped to some dummy IP Addresses. ie to add entries in /etc/hosts as in the following.

127.0.0.1 musical.ly 
127.0.0.1 tik-tak.co.il
127.0.0.1 p16-tiktokcdn-com.akamaized.net

But it does n't block the sub-domains. To block the sub-domains too, we need to update dnsmasq configuration file. Just append the following lines at the end of /etc/dnsmasq.conf.

address=/musical.ly/127.0.0.1
address=/.musical.ly/127.0.0.1
address=/.tik-tak.co.il/127.0.0.1
address=/tik-tak.co.il/127.0.0.1

I forgot about this after adding these entries last night. Just in the morning, my kids were complaining that TikTok was not working, but Internet was working.  No prizes for guessing who was happy :)

6 comments: