Last Updated: February 25, 2016
·
2.467K
· 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 *.app.dev to 127.0.0.1

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=/app.dev/127.0.0.1
  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: 127.0.0.1 app.dev sub1.app.dev subx.app.dev)

I hope it helps you!

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