What is WINS ・lmhosts file

What is WINS

 WINS stands for "Windows Internet Name Service" and is a name service specific to Windows. Manages correspondence between NetBIOS computer names and IP addresses in the Windows environment.

 Today, DNS is the established name resolution mechanism, but before the Internet became popular, Windows networks used NetBIOS instead of TCP/IP as the standard communication protocol.

 This NetBIOS utilizes NetBEUI (NetBios Extended User Interface) as a transport layer protocol.

 However, when resolving this NetBIOS computer name, if it is not cached locally, it will use broadcast to resolve the name.

 In a small network, this is not a problem, but in a large network, name resolution by broadcasting puts a load on the network, and it is not possible to resolve the names of hosts existing in the network beyond routers. This is the bottleneck.

 Therefore, you will use the WINS service. By registering your computer name and IP address on the WINS server in advance, you can reduce the network load by querying the WINS server instead of broadcasting when other hosts resolve names. .

 Since Windows 2000, the host name and computer name have been the same, so it is now common to use DNS.

* It is possible to set the computer name and host name to be different in the registry editor, but communication failure may occur due to the setting.

lmhosts file

 As a way to achieve coexistence of NetBIOS and TCP/IP without using a WINS server, there is a method of placing a file called lmhosts on each client.

 The lmhosts file is a file that manages correspondence between computer names, which are NetBIOS names, and IP addresses.

In Windows XP/Vista/8/8.1, it exists in the following location.


 The name of the file is "lmhosts.sam". This is a sample, and an example of how to define it is written in the comments when you open the file.

 Edit according to the example and then save. To use it, remove the ".sam" extension and rename it to "lmhosts".

lmhosts file (Vista)

# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample LMHOSTS file used by the Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to computernames
# (NetBIOS) names.  Each entry should be kept on an individual line.
# The IP address should be placed in the first column followed by the
# corresponding computername. The address and the computername
# should be separated by at least one space or tab. The "#" character
# is generally used to denote the start of a comment (see the exceptions
# below).
# This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts
# files and offers the following extensions:
#      #PRE
#      #DOM:<domain>
#      #INCLUDE <filename>
#      \0xnn (non-printing character support)
# Following any entry in the file with the characters "#PRE" will cause
# the entry to be preloaded into the name cache. By default, entries are
# not preloaded, but are parsed only after dynamic name resolution fails.
# Following an entry with the "#DOM:<domain>" tag will associate the
# entry with the domain specified by <domain>. This affects how the
# browser and logon services behave in TCP/IP environments. To preload
# the host name associated with #DOM entry, it is necessary to also add a
# #PRE to the line. The <domain> is always preloaded although it will not
# be shown when the name cache is viewed.
# Specifying "#INCLUDE <filename>" will force the RFC NetBIOS (NBT)
# software to seek the specified <filename> and parse it as if it were
# local. <filename> is generally a UNC-based name, allowing a
# centralized lmhosts file to be maintained on a server.
# It is ALWAYS necessary to provide a mapping for the IP address of the
# server prior to the #INCLUDE. This mapping must use the #PRE directive.
# In addtion the share "public" in the example below must be in the
# LanManServer list of "NullSessionShares" in order for client machines to
# be able to read the lmhosts file successfully. This key is under
# \machine\system\currentcontrolset\services\lanmanserver\parameters\nullsessionshares
# in the registry. Simply add "public" to the list found there.
# The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE
# statements to be grouped together. Any single successful include
# will cause the group to succeed.
# Finally, non-printing characters can be embedded in mappings by
# first surrounding the NetBIOS name in quotations, then using the
# \0xnn notation to specify a hex value for a non-printing character.
# The following example illustrates all of these extensions:
#     rhino         #PRE #DOM:networking  #net group's DC
#    "appname  \0x14"                    #special app server
#    popular            #PRE             #source server
#    localsrv           #PRE             #needed for the include
# #INCLUDE \\localsrv\public\lmhosts
# #INCLUDE \\rhino\public\lmhosts
# In the above example, the "appname" server contains a special
# character in its name, the "popular" and "localsrv" server names are
# preloaded, and the "rhino" server name is specified so it can be used
# to later #INCLUDE a centrally maintained lmhosts file if the "localsrv"
# system is unavailable.
# Note that the whole file is parsed including comments on each lookup,
# so keeping the number of comments to a minimum will improve performance.
# Therefore it is not advisable to simply add lmhosts file entries onto the
# end of this file.

* To edit the lmhosts file on Windows Vista, Notepad must be run as an administrator.

 All "#" lines are comments. To define the computer name and IP address, define them without the "#", for example: pc01

 By defining it like this, the name "pc01" will be converted to "", and you will be able to access it with the name "pc01".

A similar setting can be made in the hosts file. This is a file that manages the correspondence between host names and IP addresses.

However, if the IP address changes dynamically, such as with DHCP, name resolution cannot be performed using this method.

 The drawback of lmhosts is that it cannot dynamically resolve IP addresses that change dynamically, such as with DHCP. lmhosts defines terminals with fixed IP addresses.

If you want to dynamically manage the correspondence between NetBIOS names and IP addresses, you need to prepare a WINS server that can be managed centrally.