Using DNSMasq for Local Hostname Resolution
Solution 1
Your problem lies in your misunderstanding of the way those DNS servers are used, I don't know the exact details of the method windows uses to choose which DNS server to query but I'm betting its primary > secondary > tertiary /always/. And even if it wasn't and was round-robin, you're still going to be querying an unhelpful server 2 of the 3 times.
What will happen is the primary server will be queried. If that times out, which may be a second or two, the next server will be queried. DNS isn't a "consensus" system, if one of the remote servers is being queried, it will eventually discover the result that your hostname authoritatively does NOT exist, from its perspective as an internet DNS server.
You need your own LAN dns as the primary DNS server. The others would make suitable backup servers but I'd consider just dropping that entirely.
Also of note, your reverse dns (IP to name lookup) resolves to "hostname.lan" but your forward resolution tests are with just hostname. You should also have forward resolution for hostname.lan set up somewhere. While there can be many "name to address" forward lookups for a host, there is an expectation that there is a reverse lookup of the IP to a name, that in turn has a matching name to that IP record. It's not always critical and just makes log files whine sometimes, but some things are more sensitive to this than other things.
Also, dont forget to remove any hosts file bodgery you have put in place once you get it all working (i dont know if thats relevant to dnsmasq, never used it, I have a similar but more complicated configuration in place using ISC-BIND name server, which you can configure forwarding to other servers like you are using, or simply use it as a non-forwarding DNS server that does the full name resolution its self - which is what I have set up).
Needless to say, as you first speculated you are very very far from alone in making this set up, almost every reasonably-developed corporate LAN and a great many over-developed home LANs will have this sort of setup in place.
Solution 2
Maybe a little late , but disabling ipv6 on my wireless adapter did the trick.
Related videos on Youtube
murvinlai
Updated on September 18, 2022Comments
-
murvinlai over 1 year
Im using expressjs
I create the app like this:
app.createServer( express.cookieParser(), express.bodyParser(), myfunc1(), myfunc2() );
in myfunc1, I return next(err) for some conditions. (e.g. req.query contains some weird characters).
So, if this happen ( next(err) ), it just simply return http response 500. I try to catch the error by using:
app.error(....) or process.on("uncaughtexception" ... );
but the error doesnt go to neither of this. Where does he error go?
-
loganfsmyth about 12 yearsWhat is the code you were using for
app.error(...);
? I'm pretty sure that's the right way to do it. -
terdon over 10 yearsTry putting the pi as first DNS server, does it work then?
-
Gilles 'SO- stop being evil' over 10 yearsThe router is the right place to do this. If for some reason you don't manage to get your router to serve a name for the Pi, running dnsmasq on the Pi and having the router serve the Pi as the DNS server would work. It looks like your problem is configuring your router properly.
-
phemmer over 10 yearsAre you rewnewing the DHCP lease on the client after updating the DNS settings on the router? The DNS configuration is sent in the DHCP lease, so it has to get a new lease to get the new settings. As an alternate solution, you might also look into mDNS/zeroconf/avahi.
-
-
murvinlai about 12 yearsI have done that already. but I set the breakpoint on app.get('/500', ...) and app.error(...) but never reach there. weird.
-
Justin Beckwith about 12 yearsThat is odd. I have an example here of using a custom piece of middleware to do the error handling. This works for me: github.com/JustinBeckwith/ExpressStarter
-
Siim Liiser over 10 yearsThanks for your help iain! I understand what you're saying about how DNS is not a consensus system, so I set the Pi to the primary DNS server in my router. I then renewed the DHCP lease on my Windows machine. However,
nslookup oberon
still does not work. One thing I didn't mention in the text of my original post was that whennslookup
fails, it says that the server it used was anfe80
IPv6 address -- which I know is a reserved link-local address. But I don't know what that means for DNS. Is my Windows box querying itself?dnsflush
does not change this behavior. -
Siim Liiser over 10 yearsAnd for what its worth, LAN hostname resolution doesn't work on my iOS devices either. I haven't mentioned them yet because I have a lot more introspective power with Windows, but if my problems were really arising strictly from Windows I would not expect these devices to have the same problem.
-
Siim Liiser over 10 yearsAlso, to allay your concerns about the
.lan
domain, I configureddnsmasq
to automatically expand simple hostnames to add.lan
. Runningnslookup oberon.lan 192.168.1.151
returns the expected result ofName: oberon.lan Address: 192.168.1.151
-
iain over 10 yearsI wonder if there's a "windowsism" at work or something, naming your hosts directly under the top level domain ('oberon.') is kinda odd, oberon.lan makes much more sense. One thing to be aware of is that domain suffixes and 'search domains' are often appended to a name to resolve it, e.g. "oberon" could be being resolved and found as "oberon.lan" if lan is in the search domains. However the above queries dont seem to show this being the case, the dig specifically has the terminating period on the hostnames, but be very aware of that when testing!
-
user2948306 almost 9 yearsHmm after fixing the primary dns you will need to re-dhcp windows (resetting the adaptor should do it), then check
ipconfig /all
is showing the correct dns server being used, if that's right you might then need to flushdns. But I can't think of anything else, it should work. -
SDsolar over 6 yearsIt needs to be noted that no matter what you do,
go.microsoft.com
can never be redirected to localhost - it is hardcoded in the TCP/IP stack from Win8 onward. It also becomes hardcoded in Win7 and Vista when they download a certain (as-yet-unidentified) Windows Update. -
SDsolar over 6 yearsUpvote: Always a good idea. Unless the system is out there naked and requires it. And so far (Sept 2017) there is very little home-user equipment that meets that category, if any at all.