hosts icon indicating copy to clipboard operation
hosts copied to clipboard

(Windows) Disabling DNS Cache Service has consequences

Open M1ch431 opened this issue 2 years ago • 6 comments

It appears that Network Discovery is dependent on the DNS Caching service being active.

So, when the .bat file is applied, I can't (for example) access the Shield (Android TV) on my network.

I suggest adding a warning that something like this could occur to the end-user.

M1ch431 avatar Sep 21 '22 02:09 M1ch431

Hello! Thank you for opening your first issue in this repo. It’s people like you who make these host files better!

welcome[bot] avatar Sep 21 '22 02:09 welcome[bot]

Thank you @M1ch431. I would entertain a pull request for this modification to the docs.

StevenBlack avatar Sep 21 '22 03:09 StevenBlack

how can i enable DNS Cache Service again

NaniDaFuck avatar Nov 04 '22 11:11 NaniDaFuck

@MidnightD4wn try this maybe. There are other articles, just Google "enable DNS Cache Service".

StevenBlack avatar Nov 04 '22 21:11 StevenBlack

I'm not sure what method the batch file uses, but I almost assume it's via the registry and if so you can re-enable it via either the registry itself or a .reg file (also from an admin terminal, but that'll be a last resort).

You can create the file yourself or if you want I can upload it later.

To enable from a file just save the following to a file named <whatever_you_like>.reg (dns_cache_enable.reg for example, don't save as .txt) and then you can execute the file in any way you can execute any other program/script in Windows:

To enable the cache service:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache]
"Start"=dword:00000002

To disable the cache service:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache]
"Start"=dword:00000004

or, of course, you can manually edit directly in regedit ((Win+r (or a terminal) -> regedit) or (Start Menu->regedit)) and navigate to the above mentioned path and value:

Path

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache

Value

Start

and then enable by changing Start to 2 for enabled and 4 for disabled.

You'll need to reboot after and it's quite possible you'll need to restart twice as the internet might be disabled on the first reboot and the 2nd reboot will fix that.

I'm actually in the process of writing a C++ tool to deal with this.

I'm usually in Linux more in the last few years, but I've spent the last month or so in Windows trying to understand all the newer various changes to the way DNS (and networking in general) works (lots of things have changed since Windows 8 came out), but as I've stated before messing with stuff like changing important settings usually messes thing up in Windows in the long run (I have to enable DNS if I ever want to use WSL ☹️, but not a big deal for me because I have other various Linux machines). Disabling the cache is only a temporary solution for those who want large hosts files. I've noticed though that if you do have the DNS Cache enabled when installing a custom hosts if you let it run long enough it actually starts working after a while and if you do this for several days (rebooting in between) after installing a new hosts it eventually starts loading faster (almost like the caching stalls after a while during a session and then restarts caching on the next boot) and then after a few days it works perfect. That would mean that Windows users should update less often and only when they have free time to let their machine sit or at least not do things online. I planned a while ago to try and look into this more, but I've been stuck in Linux a while so it's hard to get over to Windows to actually do any testing and development. It's about time I get around to it.

If you have trouble figuring out how to follow my instructions above then let me know and I'll just upload the files.

Lateralus138 avatar Nov 04 '22 22:11 Lateralus138

how can i enable DNS Cache Service again

For GUI, I prefer to use Autoruns tool from Sysinternals. Download link here; https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns

sudarpo avatar Feb 10 '23 08:02 sudarpo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 18 '23 09:06 stale[bot]

Closing.

StevenBlack avatar Jun 18 '23 13:06 StevenBlack