Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Last active January 29, 2019 18:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgmoose/c26fade59f58dcebc2d9eac8a0c7a876 to your computer and use it in GitHub Desktop.
Save vgmoose/c26fade59f58dcebc2d9eac8a0c7a876 to your computer and use it in GitHub Desktop.

A fake DNS server only has handful of use cases, but in case you find yourself in need of them, here are some instructions!

The primary usage for something like this would be if you're interested in changing what IP a domain resolves to, such as redirecting an embedded's devices HTTP request to phone-home.private-protocol.proprietary.net to your own machine rather than the actual page.

The first step is to install dnsmasq with your package manager. This will usually be apt-get, yum, or brew install dnsmasq.

For every domain that you want to manually redirect, create a file in /etc/dnsmasq.d/, for instance /etc/dnsmasq.d/serebii.net.

In that file you can put a list of the domains, such as:

address=/serebii.net/192.168.1.100
address=/youtube.com/192.168.1.101

And those domains will be resolved to the respective IP by any devices that use your fake DNS server.

Any domains that are not added here, will be resolved using the DNS server on the same machine. Usually this is specified in /etc/resolv.conf.

If you want to block all domains, you can use the following dnsmasq entry:

address=/#/127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment