-4

I need to resolve both my local network devices + public internet domains from my windows PC. My local ISP's DNS server is quite sucky at resolving public domains so I want to use Google DNS for higher reliability, but also want to be able to access the local network resources in my subnet.

Although I can statically configure the NIC properties to have both Primary and Seconday DNS setting, but I also happen to move with my laptop across networks.(home\office) So I want the Local DNS to be always dynamically set but the Google DNS to remain statically configured on my NIC always.

What is the best possible approach to get DNS from DHCP and add GoogleDNS on top of it statically.

Vishal Naidu
  • 237
  • 2
  • 6
  • 3
    Fix your local DNS server. – EEAA Aug 18 '16 at 05:27
  • How can i fix my ISPs DNS server ? – Vishal Naidu Aug 25 '16 at 20:50
  • You can't fix your ISPs DNS server, but you don't need to use it. Host your own DNS server. – EEAA Aug 25 '16 at 21:02
  • @VishalNaidu You changed the requirements and details in your question... how can we help you if you're doing that? Your question is also a little confusing and you're asking to do something unusual. Also there is some question as to whether or not this is a business environment problem. Maybe you can ask a new question (since this one got closed) that is more clear and explain your problem in detail. How to solve the problem can be left up to whoever answers. – Ryan Babchishin Aug 25 '16 at 21:35
  • I dont think i changed any requirements, i just changed some sentences to be more specific. – Vishal Naidu Aug 26 '16 at 02:10
  • @EEAA how am i suppose to resolve local portals within my company when i change my DNS to public DNS servers. I want both local resolution + public IP resolution all the time be it home or office. I know google DNS will work from both place, i just want the local DNS to dynamically switch when i get a new DHCP lease whichever network i move to. – Vishal Naidu Aug 26 '16 at 02:15
  • Run a DNS resolver in your networks. Populate them with your local host names and let them recurse as necessary. This is not rocket science: it's something done by nearly every well-run network out there. – EEAA Aug 26 '16 at 02:17
  • I am not an IT Admin with domain credentials to run a DNS resolver in all the networks I hop into. I needed a client side solution. The powershell solution suggested by someone below is a good answer, but i was looking for something which requires no manual intervention and gets triggered automatically when my IP\network changes. – Vishal Naidu Aug 26 '16 at 02:50

2 Answers2

2

The best way in my opinion is to have a local forwarding DNS server.

Perhaps your DNS server is contacting the root servers? You just need to have it forward requests to somewhere fast - Google.

A DNS server can store your local records, and when a record isn't found it will forward the request to Google's DNS servers. You can have the added benefit of caching results on your server for better performance.

DNSMasq, unbound, bind do this. If you're on Windows, I can't give any suggestions - you haven't mentioned your DNS server OS. I think some routers have this functionality built in too.

According to this article, DNSMasq forwards by default to whatever is in /etc/resolv.conf. So it seems all you need to do is add your local host entries.

https://wiki.debian.org/HowTo/dnsmasq

So you get this:

request -> local dns (return if found) -> google dns ->
result -> local dns (add to cache) -> requester

Unbound works on Windows. Some others I listed may too. I'm sure there are many options for you.

https://www.unbound.net/

Now that you've explained a bit more about your situation You will need to configure the DNS server on your workstation and tell it about any internal domains and that it should query your existing slow DNS server for that info. It can then query google for everything else. You'll have to configure your workstation to query 127.0.0.1 instead of the regular slow DNS server. If you enable caching, you may find that internal lookups are faster sometimes too.

Ryan Babchishin
  • 6,260
  • 2
  • 17
  • 37
  • I am unfortunately on the client box and do not have any control on the DNS or DHCP servers in my local network. Is it possible to configure the client machine ? – Vishal Naidu Aug 18 '16 at 05:53
  • @VishalNaidu Yes you can run a dns server on your personal computer. You'll have to change your resolver to query 127.0.0.1 instead of your regular DNS servers. – Ryan Babchishin Aug 18 '16 at 06:34
  • @VishalNaidu Unbound works on windows, see my answer – Ryan Babchishin Aug 18 '16 at 06:39
  • You mean from every device i have i should run a dns server ? – Vishal Naidu Aug 25 '16 at 20:48
  • @VishalNaidu You have many workstations? You made it sound like just one. Too bad you can't just fix your slow DNS servers. You could run a DNS server on every workstation if you really need the speed. Ubuntu Linux does it on every desktop install by default. – Ryan Babchishin Aug 25 '16 at 21:19
  • @VishalNaidu I just read your question again... a few times... did it change? You only need to run one DNS server and have all workstations query it. Have it forward requests off to google's DNS and you can put your own entries in it as well **if** that's what your asking for. But you're question is confusing. Since this is for an **office**, I'm sure you'll have no problem getting a server setup to run the DNS server right? – Ryan Babchishin Aug 25 '16 at 21:27
  • @VishalNaidu I'm sorry, I can't give you an accurate answer with inaccurate and dynamically changing requirements/details. My answer is pretty much invalid. I'm wondering if I should delete it. – Ryan Babchishin Aug 25 '16 at 21:43
0

If you're on Windows, this should work in an administrative PowerShell window;

$IntName = "Wi-Fi" ; Set-DnsClientServerAddress -InterfaceAlias $IntName -ResetServerAddresses ; Set-DnsClientServerAddress -InterfaceAlias $IntName -ServerAddresses ((Get-DnsClientServerAddress -InterfaceAlias $IntName).ServerAddresses,"8.8.8.8")

It basically resets your DNS setting to get the DNS server that your DHCP provides, and converts it to a static setting adding 8.8.8.8 in the end.

"Wi-Fi" is my network connection's name. Yours might be "Local Area Connection", "Ethernet" or something like that.

This might also work.

Mer
  • 991
  • 4
  • 9
  • Wont this reset my local DNS server and always use public google dns ? – Vishal Naidu Aug 18 '16 at 05:58
  • That script gets your current DNS server and adds 8.8.8.8 to it. So, if you get 192.168.0.1 from your DHCP server, after running that, you'll have 192.168.0.1 as primary and 8.8.8.8 as secondary. – Mer Aug 18 '16 at 06:16
  • @Mer That won't work. All requests will go to 192.168.0.1, so it'll still be slow. – Ryan Babchishin Aug 18 '16 at 06:49
  • Yes, but it will ask 8.8.8.8 if it can't resolve from your local DNS server in the end. You can change the order but that might result in not being able to resolve local names. If you want to do it anyway, change the last part of the script after -ServerAddresses with ("8.8.8.8",(Get-DnsClientServerAddress -InterfaceAlias $IntName).ServerAddresses) – Mer Aug 18 '16 at 06:55
  • Thanks for clarifying. Is there a way this script can run automatically whenever client machine gets net DHCP Lease ? – Vishal Naidu Aug 18 '16 at 16:02
  • If you enable Microsoft-Windows-DHCP Client Events/Operational event log, Event Id 50058 is logged every time you get a lease. You can attach a task to this event to run that script. – Mer Aug 18 '16 at 16:09