multiple local domains with dnsmasq?
Asked Answered
L

5

9

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
Lumpkin answered 11/7, 2013 at 12:2 Comment(0)
F
7

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.

Ferne answered 13/9, 2013 at 1:28 Comment(3)
that doesn't do what the OP actually requested. Your solution maps everything in .domain to localhost. If you run dnsmasq on localhost, that works, but if you are in a virtualized environment and have .dev your localhost, .test your test VM and .build your build VM, all 3 having different IP address,. then your solution doens't work, even though the request is the same.Molli
The initial question doesn't mention a VM setup.Ferne
It doesn't have to. You can simply have a regular LAN with the same number of hosts. I have 2 PCs, 1 laptop, 1 printer and 2 phones physical devices on my LAN. Not at all uncommon nowadays. Problem still stands.Molli
M
3

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)

Molli answered 18/10, 2016 at 5:13 Comment(1)
however, I'm looking for something along this line: osdir.com/ml/network.dns.dnsmasq.general/2008-06/msg00024.html to be able to have dxe5.dev d10.dev and dxe5.test with d10.test and same for build.Molli
T
3

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

Terrify answered 11/4, 2018 at 2:34 Comment(0)
O
0

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

Overthecounter answered 18/10, 2016 at 5:31 Comment(1)
Downvoted, as this isn't an answer.Mangle
A
0

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.

Ansell answered 6/11, 2020 at 12:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.