Format of etc hosts file
This example is strictly forbidden you cannot have Physical, Virtual, Logical host with the same IP address. For more information please follow the instruction on the SAP Note Correct format regarding duplicate :. Incorrect format with duplicate IP address :. Incorrect format with duplicate FQDN :. Incorrect Format with duplicate Hostname :. Try it and see. But it would be a good idea to use.
Note that in this sense, domain means DNS domain like google. The line starting with is for IPv6. Run ifconfig lo and you should see it has two addresses. Note the entry starting with inet6. You always want the If there is a domain you can use that too, but then make sure localhost is listed second. If you want to add aliases for your machine that will lookup to the loopback address you can keep adding them as space separated values on that line.
Specifying a domain here is optional, but don't remove "localhost" from the options. I cannot speak to how Windows may differ from Linux, but the format of the local machine's definition affects the results you will obtain from the 'hostname' command.
If you experiment with re-arranging the names after the IP address and then using the 'hostname -s' short name and 'hostname -f' fully-qualified domain name or FQDN commands you will see what I mean.
It should look something like this:. If you change the order of the names you may find that "hostname -f" gives you responses like "localhost" or "hostname: system error". I know some distributions set the IPv6 name to something like ip6-localhost. I don't really use IPv6 yet, so can't comment on what the best settings for this line would be. I can just say that in an IPv4 network it works to have both lines with the same names. Sign up to join this community.
The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Incorrect format with duplicate IP address :. Incorrect format with duplicate FQDN :. Incorrect Format with duplicate Hostname :. Correct format regarding FQDN :. Incorrect format regarding FQDN :.
Any modification of the "hosts" file will require an OS restart, or at least a restart of the Network Service and the Diagnostic Agent. An example of a canonical name would be server. Any remaining names defined for the IP address are aliases or alternate names for the official host name. For example, suppose that one of the duties assigned to server. A suitable alias might then be myftp. Many times, an alias is simply the host name, without any domain suffix.
For example:.
0コメント