Skip to content

babysnakes/dot-local-dns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Local Dns Server that Resolves "**.loc" Addresses

This is a system tray icon application that resolves DNS queries of an illegal *.loc domain to either localhost or to configured addresses. Currently, it only supports Windows (I should add macOS support soon).

This app is very much a work-in-progress and everything can be changed on every release.

What is it Used For?

Do any of these scenarios sound familiar?

  • You need to serve directories via a local web browser.
  • You're a web developer working on local projects.
  • You have web services running on a NAS.
  • You run services on Docker or Kubernetes on your machine.

In these cases, an easy-to-configure web server like Caddy can help serve or proxy your websites—whether locally or on your NAS. However, to access these sites conveniently, you’ll want to use domain names instead of IP:port combinations, which means adding them to your hosts file.

You may also want to access other local services (e.g., NAS shares) by name rather than by IP address.

That's where DotLocal-DNS comes in. By default, it resolves any hostname ending in .loc (e.g., nas.loc) to 127.0.0.1. You can also configure specific hosts to resolve to custom IP addresses, making local access easier and more intuitive.

Usage

After installing the app and running it you probably want to perform 2 things:

  • Click on the tray icon and toggle the Startup at Login menu.
  • Configure your system to use DotLocal-DNS to query hosts ending with .loc.

If you want to define custom addresses (e.g., to access your NAS) click the tray icon and select Edit Records File. This will open the records text file - follow the instructions in the file for adding records.

Installation

Check the instructions in the Releases page and continue to configuring your system.

Configure Your System to Use DotLocal-DNS

Open PowerShell console as administrator and run:

Add-DnsClientNrptRule -Namespace ".loc" -NameServers "127.0.0.1"

To verify that the rule is accepted run:

# list available rules
pwsh  Get-DnsClientNrptRule

Name                             : { EE27567A-76D5-4AF1-B446-A44CFCB1CC66 }
Version                          : 2
Namespace                        : { .loc }
IPsecCARestriction               :
DirectAccessDnsServers           :
DirectAccessEnabled              : False
DirectAccessProxyType            :
DirectAccessProxyName            :
DirectAccessQueryIPsecEncryption :
DirectAccessQueryIPsecRequired   :
NameServers                      : 127.0.0.1
DnsSecEnabled                    : False
DnsSecQueryIPsecEncryption       :
DnsSecQueryIPsecRequired         :
DnsSecValidationRequired         :
NameEncoding                     : Disable
DisplayName                      :
Comment                          :

If you want to remove the app run the following command:

Get-DnsClientNrptRule | Where-Object { $_.Namespace -eq ".loc" } | Remove-DnsClientNrptRule

You should be prompted to approve deleting the rule. If something goes wrong you can run the Get-nsClientNrptRule command as described above, Note the Name and run as administrator:

Remove-DnsClientNrptRule -Name "{EE27567A-76D5-4AF1-B446-A44CFCB1CC66}"

Credits

  • Big credit goes to Emil Hernvall for his great dnsguide. The entire DNS implementation is copied (with slight modifications) from his guide with his permission.
  • This GitHub issue for helping solve UDP connection resets in windows.

About

A toy dns server that serves .local addresses

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages