Skip to content

Instantly share code, notes, and snippets.

Last active January 29, 2019 18:42
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

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 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/

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


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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment