DNS redirect in Windows

DNS redirect in Windows

I probably need something small (dnsmasq) for Windows

I will go with simple Hosts edition, and with open-source tool: hostsedit I really don’t need anything else.

Simple and manual

Tool to edit hosts file directly: http://www.holistech.co.uk/sw/hostsedit/hostsedit.html :: command line windows hosts file editor

Similar tool: HostsEditor https://github.com/teamaton/toolbelt/downloads :: Downloads · teamaton/toolbelt · GitHub https://github.com/teamaton/toolbelt#readme :: teamaton/toolbelt · GitHub

Hosts Commander
http://code.google.com/p/hostscmd/ :: hostscmd - Useful command-line tool for manipulating hosts file (C#, .NET 3.5/Mono 2.8+, Windows/Linux) - Google Project Hosting

Netsh built-in command to redirect DNS to virtual machine http://www.petri.co.il/configure_tcp_ip_from_cmd.htm :: Configure TCP/IP from the Command Prompt

You could set Windows DNS settings with: netsh interface ip set dns name=“Local Area Connection” source=static addr=192.168.0.X

The ones that are easy to install:

  • QuickSetDNS by NirSoft to easily change the DNS servers. Setup with scoop install quicksetdns. Strange enough, it is the best - simple and to the point.
  • DNS Jumper is for switching DNS servers with GUI available via scoop scoop install dnsjumper. Works nice but looks “like circus”.
  • DNS Changer installable with winget install --id 9MW2MLV576P7, but you can’t add or remove DNS servers in free version, you forget about it

Others:

Manual

The actual location of hosts file is defined by the following Registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath
Value should be: %SystemRoot%\System32\drivers\etc.

DNS Proxies

pDNS Wildcard and question-mark support for hosts file http://www.studiomaraton.com/bzivkovic/ :: Index of /bzivkovic http://www.studiomaraton.com/bzivkovic/readme-pdns.txt ::

The problem is it can’t be deamonized (that is solvable), and needs a restart to reload hosts file (also solvable). But it’s poorly written.

pdns /ho:%SystemRoot%\System32\drivers\etc\hosts

Shitty: made in PHP and then packed with http://upx.sourceforge.net/

Acrylic DNS Proxy And has Acrylic HOSTS file with wildcard support. And it’s open source. http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=Home :: mayakron’s deep

Very nicely written, but needs service restart on every change in hosts file. And, this hosts file is not the same as in Windows but another one (supporting wild-cards). But, it can be symlinked.

Dual DHCP DNS Server Very good one. http://sourceforge.net/projects/dhcp-dns-server/ :: Dual DHCP DNS Server | Free software downloads at SourceForge.net

Again, this one is also ignoring hosts file entries.

FastCache (freeware) http://www.analogx.com/contents/download/Network/fc/Freeware.htm :: Network Downloads : FastCache /// AnalogX

The big and old one http://tftpd32.jounin.net/#Top :: TFTPD32 : an opensource IPv6 ready TFTP server/service for windows : TFTP server

Networking Software for Windows

Mangling Hosts file

AngryHosts (not free) http://angryhosts.com/features/ :: Features angryhosts Accepts wildcards.

Interesting tools

http://www.abelhadigital.com/hostsman :: HostsMan - abelhadigital.com

Acrylic

DNS forwarder for Windows / Dnsmasq for Windows. It’s really not needed

Set couple of variables:

set DNSPROXY_INSTALL_ROOT=C:\Program Files\DNSProxy
ree -m DNSPROXY_INSTALL_ROOT "%DNSPROXY_INSTALL_ROOT%"

set DNSPROXY_HOSTS=%DNSPROXY_INSTALL_ROOT%\AcrylicHosts.txt
ree -m DNSPROXY_HOSTS "%DNSPROXY_HOSTS%"

By default, Acrylic uses OpenDNS servers, but I prefer Google’s ones. So, change that:

sed -i.bak -e "s/^\(PrimaryServerAddress\)=.*$/\1=8.8.8.8/g" ^
    -e "s/^\(SecondaryServerAddress\)=.*$/\1=8.8.4.4/g" ^
    "%DNSPROXY_INSTALL_ROOT%\AcrylicConfiguration.ini"

Set our proxy as default DNS server for our machine. This will find the first interface named like this, and set DNS as it should be:

netsh interface ip set dns "Local Area Connection"          static 127.0.0.1
netsh interface ip set dns "Wireless Network Connection"    static 127.0.0.1

Creating a symlink to system hosts file is definitely not working:

ren "%DNSPROXY_INSTALL_ROOT%\AcrylicHosts.txt" AcrylicHosts.original.txt
mklink /H "%DNSPROXY_INSTALL_ROOT%\AcrylicHosts.txt" "%SystemRoot%\System32\drivers\etc\hosts"

Restart DNS service:

net stop AcrylicController & net start AcrylicController

Vagrant TODO: First in Ruby create lines like for hosts file (with VM UUID). Then compare if anything changed. If it is, obviously change that in file AcrylicHosts.txt, and restart service.

I can precompile Acrylic with Delphi 10 Lite. I wrote an email to author, but if he doesn’t do anything, I prepared everything to make a patch.


Acrylic - Autoconfigure Windows 10 Network Adapters to use Acrylic DNS Proxy · Issue #36 · cretueusebiu/valet-windows


On Android, the best tool to quickly change DNS is tool iTXTech/Daedalus that creates a VPN tunnel to modify the DNS settings, and is available both on F-Droid and Google Play


date 23. Apr 2015 | modified 10. Jun 2024
filename: Windows » DNS & Hosts Files