Question

So I'm using dnsmasq for my local dev environment & I need to set it up to use multiple domains ex. (.dev, .test, .somethingelse) how can this be done?

currently It's working with .dev only

this is how my dnsmasq.conf looks like

address=/dev/127.0.0.1
listen-address=127.0.0.1

No correct solution

OTHER TIPS

For every (sub)domain you want to server locally, add the following entry to your dnsmasq.conf:

address=/.domain/127.0.0.1

Now let your OS know, that you want to redirect requests to this domain to your local dnsmasq nameserver. Do this by creating a file "domain" in "/etc/resolvers".

/etc/resolvers/domain has the following content:

nameserver 127.0.0.1

More info about the resolver thing.

for me, address=/.aaa.com/.bbb.com/127.0.0.1 do the trick.

A more generic answer would be to have in /etc/dnsmasq.conf

local=/mylan/ 

and in /etc/hosts

192.168.1.3 dev dev.mylan 
192.168.1.3 test test.mylan 
192.168.1.4 build build.mylan 

as per https://serverfault.com/questions/136332/setting-up-dnsmasq-for-a-local-network

(note that the solution comes in aid for the DHCP settings where you cannot have 2 hosts on the same IP, as the OP liked)

.dev is not recommended to be used in development as Google actually owns that top level domain.

You might want to use reserved TLDs, like .localhost, for development.

Good article about the same problem: https://web.archive.org/web/20180722223228/https://iyware.com/dont-use-dev-for-development/

In your /usr/local/etc/dnsmasq.conf add:

address=/dev/test/127.0.0.1

And then create files: /etc/resolver/dev and /etc/resolver/test. Both with content:

nameserver 127.0.0.1

From now all xyz.dev and xyz.test domains will point to 127.0.0.1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top