Windows hosts file: aliases without explicit IP address?

2

I know that you can set up host names in %SystemRoot%\System32\drivers\etc\hosts

But it seems you must put an IP address at the beginning of the line, which makes it fragile if you really want to resolve a host name.

So you can't put, for instance:

mail.google.com   togooglemail

...since it doesn't start with an IP address. You could ping mail.google.com and put that IP address in, but you know that's eventually going to let you down.

Is there a way, in this file or elsewhere, achieve this local DNS mapping without explicit IP address?

(FYI, we're working around a field-entry limitation in some legacy software.)

Similar to this Q.

JimB

Posted 2019-06-17T19:32:25.460

Reputation: 507

1"Is there a way, in this file" No. "elsewhere" No, at least built into Windows. – DavidPostill – 2019-06-17T19:35:21.410

1Run your own DNS server with a fake TLD (example.test) and use CNAME data. – ivanivan – 2019-06-17T20:05:58.657

Any chance there's an easily-configurable open-source package to run such a DNS server? – JimB – 2019-06-18T03:56:41.123

Answers

3

The Windows hosts file supports only ip->name mappings, it does not support any other standard DNS record types.

You could try using a plugin in the browser, instead of editing the hosts file, such as Redirector for Firefox or Redirector for Chrome.

Otherwise, you could use a local DNS server. One I have found is the free and simple Technitium DNS Server, but there are many others such as OpenDNS.

harrymc

Posted 2019-06-17T19:32:25.460

Reputation: 306 093