Last Updated: February 25, 2016
· qw3r

NetworkManager + dnsmasq = wildcard subdomains for development

I'm developing an application which using multiple subdomains. These subdomains are customizable by the user, so i can't specify them in the my hosts file.

I'm using NetworkManager to handle my connections which can use dnsmasq for caching dns queries, but the instance can be configured easily to do other things: in my case resolving * to

So, to the point of this post

  1. add dns=dnsmasq line to the [main] section of /etc/NetworkManager/NetworkManager.conf
  2. create a file /etc/NetworkManager/dnsmasq.d/local-development.conf with the content address=/
  3. restart the network manager (on my system it can be done with sudo systemctl restart NetworkManager)

You can remove the lines from /etc/hosts you may have used to route to your app )in my case:

I hope it helps you!

Note: If you don't have to work off-line then using * is much more simpler :)