I am trying to redirect all outbound DNS requests on my local network. I have a few devices made up of PC's, cell phones, etc. How would I go about redirecting (ex: www.domain.com to

Basically spoofing www.domain.com to so anyone on the network will not be able to connect to www.domain.com.

  • I have a home server on
    – Etienne
    Jan 9 at 23:00

Two solutions to reply specificaly to your question :

Modify hosts file to reflect your desire, an example on how to use this file is present in the file itself.

Configure a local DNS server to lie about the resolution, most of the time, routers can serve as DNS servers.

How to configure said DNS server will depends on which software handle that, assuming your router uses dnsmasq, as it is common for small routers, you would need to add this line in your configuration file.


If your plan is to prevent connection to this domain, you may consider using this instead, as this will make the DNS server reply that the domain does not exist.


But the best method is to create a netfilter rule on the router to drop anything going to and coming from the IP of said domain, which is different from your question.


If this is an IPv6, you need to replace iptables with ip6tables. If domain uses both, you must create rules for both stacks.

  1. Configure local DNS server: Set up a dnsmasq on

  2. Configure netfilter: iptables -t nat -A POSTROUTING -p udp --dport 53 -j REDIRECT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.