MikroTik Router Configuration
Or how to make social media less interesting

Most home networking equipment supports some kind of blocking mechanism to keep you from accessing certain sites, but trying to quit things cold turkey usually ends up with just turning off the rule. Instead I wanted to apply traffic shaping rules to certain sites so that I could progressively make them slower until they are no longer as addicting. In practice after the delay got to about 15 seconds to load a page I would have already thought of something better to do with my time than scroll.

Unfortunately usually only commercial networking equipment supports traffic shaping. Luckily the pride of Latvia, MikroTik uses the same operating system, RouterOS in their commercial and residential focused products. That makes what I'm looking to do possible, but the downside is that it took a while to figure out. Special thanks to mladen074 for the crux of the problem.

  • Reset your device to original settings by holding down the reset button while power cycling. Release the button when the main light starts blinking
  • Start redirecting all DNS requests to your devices DNS server /ip firewall nat add disabled=no chain=dstnat protocol=udp dst-port=53 action=redirect to-ports=53 /ip firewall nat add disabled=no chain=dstnat protocol=tcp dst-port=53 action=redirect to-ports=53
  • Add a script to filter the dns cache entries looking for ones you want to slow :foreach i in=[/ip dns cache find name~"fbcdn|reddit|etc"] do={ :do {/ip firewall address-list add list=social address=[/ip dns cache get $i name];} on-error={}}
  • add scheduler to run your script on a regular interval
  • disable fast path under ip settings, or else none of your packet mangling will work
  • Under Ip > Firewall > Mangle > Add New select chain:prerouting Src. Address List:social Action:mark packet and pick a name for your packet mark.
  • Create a simple queue for your packet mark to be slowed on downloads