0

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 192.168.1.80).

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

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

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.

address=/www.domain.com/192.168.1.80

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.

server=/www.domain.com/

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.

iptables -A INPUT -s SERVICE_IP_HERE -j DROP
iptables -A OUTPUT -d SERVICE_IP_HERE -j DROP

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

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

  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.