My question is how can I modify the hosts file of the router (If it exists), And redirect users to my server when they prompt a specific website?

  • Maybe ask two separate questions. DNS redirects don't really have anything to do with the telnet service on your router. Aug 5, 2016 at 12:03
  • 1
    @VerbalKint Ok i'll edit that out, do you have an answer?
    – user90685
    Aug 5, 2016 at 12:04
  • You'd need DNS server where you can add new zone with your domain you want to block.
    – Aria
    Aug 5, 2016 at 12:12

2 Answers 2


It depends a lot on the router. Most household/everyday routers don't have the capability to implement local DNS like you're referring to. See here: https://superuser.com/questions/311877/why-do-most-routers-not-include-local-dns

If you want to do something client side, you could play around with network shortcuts that map to media servers and the like when you enter in the name of the shortcut in your web browser. Although this doesn't really make sense for large networks, at that point you should have a router that has this kind of functionality built-in already.

Also, this general sort of thing can be exploited in dns redirect attacks, which I feel like you may be alluding to. In the attack, a computer connected to something like a coffee shop wifi network can spoof the router and provide a fake dns/hosts file. This allows an attacker to redirect users, but remember that the attacker's machine is handling redirects, not the router. Not to mention most people use https and verify site security certificates to minimize risks like these.

And when you think about it, the world would be that much more scary if the average router could have its own hosts file. You could be on some coffee shop's WiFi and the sites you visit could be fake copies designed to steal your personal data. Sure, the store owners wouldn't do it, but someone could hack their fifteen year-old router and exploit the theoretical hosts file, or connect their own WiFi router to some unsuspecting company's LAN and cause all sorts of chaos.


Your goal could be accomplished easily and inexpensively on your home LAN with pi-hole. It allows you to direct DNS requests according to your needs, using a public resolver like Cloudflare or Google for sites that don't need redirection.

Simply place your RaspberryPi upstream of your router, and it's just one-line to install and get running.

Pi-Hole's initial release was June 15, 2015- and likely wasn't yet popular enough to be a suggested solution to this question.

You must log in to answer this question.