Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just set up dnsmasq in my home lan for the first time. I got it as DHCP and DNS.

Something strange is that when I ping DEV01 (which has dnsmasq) it resolves to 127.0.0.1 and I don't know why it is doing so.

jorgee@jorgee:~$ nslookup dev01 192.168.1.2
Server:     192.168.1.2
Address:    192.168.1.2#53

Name:   dev01
Address: 127.0.1.1

Is anything else to configure?

share|improve this question
    
Is dev01 on the same physical machine as dnsmasq, and what is the contents of /etc/hosts ? –  davidgo Feb 1 '13 at 5:58
    
@Hi, yes its the same machine, its the host of dnsmasq. –  Jorge Feb 1 '13 at 12:15
    
Does your /etc/hosts file have a line like "127.0.0.1 dev01" in it ? The reason why dev01 is coming up as 127.0.0.1 is because it is !!! 127.0.0.1 (also known as localhost) is an address assigned to every machine so that it can refer to itself !!! Different distros would handle it differently I imagine, so I would not be surprised if your distro has added dev01 to the hosts file with a definition of localhost, which is then translated into the dns by dnsmasq. A solution might be to update /etc/hosts or force an override for that machine only in dnsmasq.conf. –  davidgo Feb 1 '13 at 18:37
    
@davidgo Thanks that solved it, I've added changed "127.0.0.1 dev01" to "192.168.1.2 dev01". Is it possible to use that only for local requests but not for other pc's requests? –  Jorge Feb 2 '13 at 23:51
    
Not sure I understand what you are asking. It You should only need to change 127.0.0.1 to the address of your server on your server and DNSMasq will add it into the DNS for other machines to use. In an ideal world you should refer to dev01 by its real IP address, as 127.0.0.1 is named "localhost" - specifying the machine name as localhost is, I believe, a bit of a hack for when you don't know the name of the resource. –  davidgo Feb 3 '13 at 0:53

1 Answer 1

up vote 0 down vote accepted

The solution is to change the hosts file to reflect the IP Address of the network interface (ie change 127.0.0.1 to 192.168.1.2).

This works because DNSMasq is translating the Domain name into the IP address based on the contents of the "hosts" file, and the hosts file is set to point the domain name to 127.0.0.1 which is a special address each machine on the Internet has so it can refer to itself even without a valid Internet connection - but 127.0.0.1 does not work so well for a server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.