2

I'm reviewing a hosts file on a windows machine and I noticed that in addition to obvious comments that start with a # character, it also has lines that are comments but start with two tabs (or in some cases with several spaces), and no # or IP address before them. These "comments" follow immediately after well defined comment lines. EG:

# Obviously a comment line that starts with #
\t\t Is also a comment, but line starts with two tabs
\t\t Possibly is treated as a comment continuation??

From this Microsoft page, it says about hosts files:

The Hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (Tabs are often preferred for historical reasons, but spaces are also used). Comment lines may be included, and they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored.

Which implies that comments should start with a #

The Wikipedia page on Hosts files is basically identical.

Is my hosts file malformed (and the issues are being ignored)? Or is there some arcane format that allows for comments to start without a leading # (possibly a comment continuation format from the previous line)?

0

1 Answer 1

3

RFC 952: 2. Continuation lines are lines that begin with at least one blank. They may be used anywhere 'blanks' are legal to split an entry across lines.

if text is following an entry, then it is text strings which are aliases.

Is your file malformed? Yes. Is your system "ignoring" malformed lines? Perhaps, you can check the alias. And look in the log for messages. But "ignoring" malformed data is part of the design of the unix networking system, and that's not arcane: that's the way the system was designed.

2
  • 2
    That's the wrong format. The format of BSD /etc/hosts files doesn't have anything in common with DoD HOSTS.TXT files, they only share the name and purpose. Commented Mar 29, 2024 at 5:25
  • 1
    I also agree that this is the wrong RFC, but it would makes sense if the same comment style applies to the hosts file. However, RFC 952 doesn't prove that. Commented Mar 29, 2024 at 12:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.