What's new

how-to nslookup hostname to append domain

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

rigstars2

Occasional Visitor
I’ve configured dnsmasq on router..it appears to be working but just have a couple questions. dnsmasq.conf has..

domain=private
expand-hosts
lan=/private/

resolv.conf has...
nameserver 127.0.0.1

hosts file has ...
192.168.1.5 m1

All clients are pointing to dnsmasq router for dns...
If I do nslookup 192.168.1.5 it returns 192.168.1.5 m1.private .. that is right
If I do nslookup m1.private it returns m1.private 192.168.1.5.. that is right

however, if I do nslookup m1 it returns
m1 192.168.1.5 ... why does it NOT return m1.private? Meaning, why is the ‘private’ domain not appended? Is this normal output if I just nslookup just the hostname?

To fix this I have to add the domain in the search field for each of the various clients. Is there a way to have this done globally...
 
It's because your hosts entry is incomplete. It should read:

192.168.1.5 m1.private m1

Also, the order in which the hostnames are written effects what is returned.

P.S. AFAIK "lan=/private/" is not a valid parameter, I think you mean "local=/private/".
 
Last edited:
Colin,

I added your suggestion and restarted dnsmasq..
192.168.1.5 m1.private m1

nslookup m1 on my macbook terminal.. it still not appending the domain.. results below -

server: 192.168.1.1
address: 192.168.1.1#53

name: m1
address: 192.168.1.5

and lan=/private/ was a typo.. i had local=/private/
 
I append a few more files just in case ..also, nslookup 192.168.1.5, nslookup m1.private and nslookup m1 all return the domain appended from the router ..its just nslookup m1 doesn't from the client machines ..

### /jffs/configs/hosts.add
192.168.1.5 m1.private m1
192.168.1.6 m2.private m2

### /etc/resolv.conf
nameserver 127.0.0.1
 
OK I think see the problem. What is the complete output of this:

nslookup 192.168.1.5
 
this is from my MacBook ..

Server: 192.168.1.1
Address: 192.168.1.1#53

5.1.168.192.in-addr.arpa name = m1.private.

------------------

this is from my router/dnsmasq ..

Server: 127.0.0.1
Address 1: 127.0.0.1 localhost.localdomain

Name: 192.168.1.5
Address 1: 192.168.1.5 m1.private
 
OK. There was a slight misunderstanding initially on my part of what part of the output you were talking about.

On a client PC there is this output:
Code:
# nslookup test
Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   test
Address: 192.168.1.22
In this line "Name: test", test is the string you are sending to the DNS server. And "Address: 192.168.1.22", 192.168.1.22 is the reply.

The only way that "Name:" would be different is if you sent a different query, i.e.
Code:
# nslookup test.home.lan
Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   test.home.lan
Address: 192.168.1.22
There is an exception though if your client automatically appends a suffix for you. Windows will do this if it is configured as part of a local domain, so will Unix.

If I add "search home.lan" to resolv.conf on my Linux server it appends the domain name:
Code:
# nslookup test
Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   test.home.lan
Address: 192.168.1.22

Doing a reverse lookup on the IP address is different. If you look carefully you will see there is no "Name:" in the output. The DNS server has had to create the in-addr.arpa name for you.

Finally, the behaviour of the nslookup client on the router itself is slightly different. Because it knows you're talking about a local name it looks directly at the etc/hosts file. It returns the first matching IP address and name it finds in the file.


So in summary, if you want the "Name:" field to contain the domain then you will have to pass it one. It is a client issue and nothing to do with the DNS server.
 
Last edited:
Thanks for researching ..So, even if I put 'search private' in the resolve.conf on my router ..the clients still won't append it?

on my MacBook ..added 'search private' to /etc/resolv.conf ..works but like you said its a per client setup ..

nslookup m1

Server: 192.168.1.1
Address: 192.168.1.1#53

Name: m1.private
Address: 192.168.1.5
 

Attachments

  • Screen Shot 2018-07-20 at 6.56.54 PM.png
    Screen Shot 2018-07-20 at 6.56.54 PM.png
    14 KB · Views: 725
So, even if I put 'search private' in the resolv.conf on my router ..the clients still won't append it?
No, because they have no knowledge of how the server is configured. The "Name:" field is simply what the client is sending to the server.

Are your clients DHCP clients? I know almost nothing about mac's, but with Windows DHCP clients the domain name is automatically configured from the server. So you don't need to specify it individually on each PC.
 
I have a combination of static (outside of dhcp range) and dhcp clients .. thanks for the assistance ..
If I ever stand up a domain server ..I'll keep this thread in mind ..
 
I'd have thought your DHCP clients should be automatically picking up the domain from the dnsmasq "domain=private""dhcp-option=lan,15,private" parameter. So they shouldn't need to have the "search" configured manually.

As for your static PC's, if they are truly static (and not just reservations in DHCP), then you're having to enter all their networking parameters anyway, like IP address, netmask, gateway, DNS, etc. So configuring the search domain as well isn't that much more work.
 
Last edited:
EDIT: Maybe I'm expecting too much from the macos' DHCP client. I just assumed it worked like other operating systems.
 
I thought so too ..but I just tested on my windows dhcp client ..and it didn't append the domain until after I added 'private' to windows7 dns suffix settings ..
the static ip macbook I understand now ..but the dhcp client is bewildering to me ..
 
does the order of this matter (dnsmasq.conf)?

bind-dynamic
interface=br0
interface=pptp*
no-dhcp-interface=pptp*
no-resolv
servers-file=/tmp/resolv.dnsmasq
no-poll
no-negcache
cache-size=1500
min-port=4096
domain=private
expand-hosts
bogus-priv
local=/private/
domain-needed
listen-address=127.0.0.1
listen-address=192.168.1.1
server=8.8.8.8
server=208.67.222.222
dhcp-range=lan,192.168.1.2,192.168.1.7,255.255.255.240,604800s
dhcp-option=lan,3,192.168.1.1
dhcp-option=lan,15,private
dhcp-option=lan,252,\n
dhcp-authoritative
 
I thought so too ..but I just tested on my windows dhcp client ..and it didn't append the domain until after I added 'private' to windows7 dns suffix settings ..
the static ip macbook I understand now ..but the dhcp client is bewildering to me ..
Strange, I've never had problems with Windows 7. Here's my settings for comparison:
1.png 2.png 3.png
Code:
C:\Users\Colin>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : home.lan
   Link-local IPv6 Address . . . . . : fe80::a835:b187:2fdc:22b3%12
   IPv4 Address. . . . . . . . . . . : 192.168.1.238
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
 
Last edited:
I've had to correct a previous post :rolleyes:. The DHCP clients pick up the "dhcp-option=lan,15,private" parameter, not the "domain" parameter.
 
I should of mentioned that the dhcp client is wifi ..so, shouldn't the parameter be dhcp-option=wifi,15,private ?
 
No it's "lan", unless you've got some non-standard bespoke dnsmasq setup that I'm not aware of.
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top