Technical article 100037

What is the "lmhosts" facility and how is it used?

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

What is the "lmhosts" facility and how is it used?

Solution

The "lmhosts" facility allows NetBIOS packets to be routed across subnet boundaries. These network subnets exist on either side of software or hardware routers. Workstations in an IP network will have different network addresses. NetBIOS uses broadcasts for name resolution and these broadcasts are not forwarded by IP routers. However, NetBIOS over TCP/IP or TPI/NetBIOS as defined by RFC/1001, 1002, will allow routing by utilizing both the IP address of a workstation and its NetBIOS name.

The "lmhosts" facility can be set up to allow network data packets to be exchanged between a client and server system (client lmhosts), and between a server and another server (server lmhosts). Variations exist to the above depending on whom initiates the conversation. Some scenarios are detailed below.

Client lmhosts:
Figure (a).
+------------+
| Client A   |  IP 193.0.1.55   ( C:\WINDOWS\LMHOSTS )
+------------+
     |          "BARNEY"
     |
+|----------------------------------------------|+   Network A
                                          |
                                          |
                                     +----------+
                                     |  Router  |
                                     +----------+
                                          |
+|----------------------------------------------|+   Network B
                                                |
                                                |
                                          +------------+
                                          |  Server B  |  IP 193.0.2.23
                                          |            |
                                          +------------+  "SERVERB"
In figure (a), a PC client, such as a Microsoft Windows for
Workgroups PC, will attempt to converse with a remote SCO Advanced
File and Print Server or LAN Manager Server or Microsoft NT 3.51/
NT4.0 Server. If it simply broadcasts a request to the remote
server that it knows as the NetBIOS name SERVERB, the broadcast
will not traverse the router. To transmit a data packet from
BARNEY, the NetBIOS name SERVERB must be resolved to an IP address.
The "lmhosts" facility is one way to enable the TCP/NetBIOS stack
to resolve that name.  NetBIOS will update its internal NetBIOS name
cache using the information provided in the file. If no routers are
involved, the NetBIOS name will simply be resolved by the local
receiver replying to the initial query broadcast from the
transmitter workstation.

NOTE: The "lmhosts" facility is one way to resolve a NetBIOS name to an IP address. Other mechanisms for name resolution such as DNS (Domain Name System) or Microsoft WINS (Windows Internet Naming Service) may be used on the system. The overall order in which each mechanism is chosen for name resolution is dependent on the particular operating system or product set. Ultimately, broadcasts will try to be avoided to reduce network traffic and generally should be the last mechanism in the sequence.

In the Microsoft Windows for Workgroups operating system, the file resides as "C:\WINDOWS\LMHOSTS". Its format is as follows:

149.124.10.4    server1         #main office server
182.102.93.122  joe3            #joe's database server

A sample "lmhosts" file (C:\WINDOWS\LMHOSTS.SAM) is provided, by default, by the operating system and the actual lmhosts file used is created by copying this sample file and editing in the required entries. Alternatively, a file may simply be created with your favorite editor. In the Microsoft Windows NT 3.51 operating system, LMHOSTS and LMHOSTS.SAM reside in the "C:\WINNT34\SYSTEM32\DRIVERS\ETC" directory. In other implementations of a PC TCP/IP NetBIOS protocol, the file may be called something different. For example, within the FTP Software OnNet for Windows product, the file is called "C:\PCTCP\NB-NAMES".

Several Microsoft LAN Manager 2.x extension features, such as
the "#PRE" and "#DOM" flags, are also used within the lmhosts file.
The "lmhosts" file will both pre-load a cache and be later parsed
for names.  For example:
193.0.2.23      serverb         #PRE    #DOM:sales

The "#PRE" flag improves performance by causing the entry to be pre-loaded into the system's NetBIOS name cache on startup. By default, if no mapping is found in the cache, the system attempts to contact the server itself with a broadcast before checking the respective "lmhosts" file. If the client lmhosts file is updated, the name cache must also be updated by restarting the system.

The "#DOM" flag following an entry will cause that entry to be associated with a particular domain. This affects how the browser and logon services behave in TCP/IP environments. The inclusion of "#DOM" flag implies that a client "login" request can be directed to that server when it needs to log in to the specified domain.

NOTE: If the client is Microsoft Windows 95, the "#PRE" flag must be set if DNS has been enabled on that system. The "lmhosts" file is not parsed at any later stage, so make sure that all entries are pre-loaded. Microsoft WINS is relied on to resolve logon servers but that does pre-suppose that a WINS server is configured for the clients on that network.

A workaround for AFPS, which does not use WINS, is to place the logon server as a "lmhosts" entry in the following form:

<IP address>    "<Domain>       \0x1c"      #PRE
^^^^^^^^^^^^^^^^^^^^
  20 characters

When a client calls a logon server, it uses a 16 byte NetBIOS name terminated by the hexidecimal character "1c" (NOTE: "SERVERB" is a NetBIOS name, "\\SERVERB" is not). Using the syntax above, it finds that it already has a NetBIOS name of this form in its cache so it does not need to call WINS or parse the "lmhosts" file. However, it is restricted to one logon server and this could be unavailable at some stage.

Pre-loading the NetBIOS name cache is not necessary on other network clients but, as mentioned, it will improve performance.

Refer to the sample files and the particular client operating system documentation for more extensions and details on their settings.

In setting up the PC client, ensure that it can "ping" the remote server. The client's default TCP/IP gateway must be configured (DNS disabled). For example, with Windows for Workgroups, choose "Networks", highlight the "Microsoft TCP/IP-32 3.11b" transport, choose "Drivers" and then "Setup" and enter the Default Gateway IP address. For a Microsoft Windows 95 client, the default gateway can be set by choosing "Settings", then "Control Panel", then "Network Protocols". Highlight the TCP/IP protocol and click on "Properties".

Server lmhosts:
Figure (b).
+------------+
| Server A   |  IP 193.0.1.55         ( /etc/lmhosts )
+------------+
     |          "SERVERA"
     |
+|----------------------------------------------|+   Network A
                                          |
                                          |
                                     +----------+
                                     |  Router  |
                                     +----------+
                                          |
+|----------------------------------------------|+   Network B
                                                |
                                                |
                                          +------------+
                                          |  Server B  |  IP 193.0.2.23
                                          |            |
                                          +------------+  "SERVERB"
( /etc/lmhosts )

If the PC client is replaced in the scenario as in figure (b) above by an SCO Advanced File and Print Server or an SCO OpenServer 5.0 operating system, together with the SCO LAN Manager Client (LMC) utility, again the problem of NetBIOS name resolution is present. An AFPS server configured in, for example, a trust relationship will need to be able to resolve the NetBIOS name of SERVERB to an IP address. Generally, UNIX servers will not have an "lmhosts" facility. This is provided with a "server" lmhosts file called "/etc/lmhosts" which is contained as part of the SCO Networking Supplement 1.0.0. This supplement is also implemented as part of the SCO OpenServer 5.0.2 operating system (Enterprise version only). The file "/etc/lmhosts" format is the same as the client lmhosts file. An example is:

134.148.208.10  sserv  #DOM:london  # London - sales server

To enable server-to-server communications, for example, between a primary domain controller (PDC) and a backup domain controller (BDC) engaged in account or file replication across a router, each server should be configured with an lmhosts file containing an entry for its opposite server in the above format. The "#DOM" flag ensures that NetBIOS will send a copy of all packets broadcast to that domain to that server. While the broadcast will go to the local subnet, it will also then reach the remote server.

See the SCO Networking Supplement Release Notes and lmhosts(SFF) for file extension and setup details. Briefly, to set up lmhosts:

Log in as the "root" user on the SCO OpenServer system running the SCO Advanced File and Print Server.

Stop TPI/NetBIOS if it is running on the system:

#netbios stop
Stopping TPI NetBIOS...
TPI NetBIOS stopped.

Create the file "/etc/lmhosts" and add the following line, for example:

193.0.2.23      serverb  #remote afps server
Change the permissions of the file:
#chmod 444 /etc/lmhosts
Restart TPI/NetBIOS:
#netbios start
Starting netbios: nbd dlnbhosts#

The dlnbhosts utility will download the hostname entries from the "/etc/ lmhosts" file to the NetBIOS daemons internal cache.

Server lmhosts and clients.
Figure (c).
+------------+
| Client A   |  IP 193.0.1.55   ( C:\WINDOWS\LMHOSTS )
+------------+
     |          "BARNEY"
     |
+|----------------------------------------------|+   Network A
                                          |
                                          |
                                     +----------+
                                     |  Router  |
                                     +----------+
                                          |
+|----------------------------------------------|+   Network B
                                                |
                                                |
                                          +------------+
                                          |  Server B  |  IP 193.0.2.23
                                          |            |
                                          +------------+  "SERVERB"
( /etc/lmhosts )

In figure (c) above, a PC client is communicating with a server on the other side of a router using its local "lmhosts" file. The server can reply to the incoming packets as it has received the workstation's IP address as part of the packet. (NOTE: In addition, SLS OSS449A provides an auto-cache facility within NetBIOS that caches the initial incoming logon request in anticipation of the AFPS server handling any subsequent allowed logon from that client.) However, if the server initiates the communication in, for example, issuing an alert or using client printing rather than issue a broadcast to the network, the inclusion of an entry for that "client" in the server "lmhosts" file will enable the server NetBIOS to resolve that name and provide these services efficiently.

NOTES:    SCO periodically issues supplements for the operating system and
          network subsystem, such as the Network Supplement Release 1.0.0
          and Support Level Supplement (SLS) OSS449A. It is important to ensure
          these are loaded as they will generally contain fixes and additional
          functionality. SCO TPI/NetBIOS is a component of the network
          subsystem of the operating system, not a component of AFPS.

An entry in the server "/etc/lmhosts" file is only necessary when server-to-server communication or server-to-client alerts or server-to-client printing over routers is required.

NOTE:     Support Level Supplement (SLS) OSS449A is now obsolete. This
          SLS is no longer available through SCO. SLS OSS449A has been
          superseded by SLS OSS449F. SLS OSS449F includes all fixes from
          previous versions of OSS449.

See also

IT tcpip/486, "What is the SLS OSS449F Network Maintenance Supplement?".

lmhosts(SFF), dlnbhosts(ADMIN), nbd(ADMIN).

IT afps/6, "How do I load and use a LAN Manager Client module with SCO AFPS?".

"NetBIOS routing", Page 10, "SCO OpenServer Networking Supplement Release 1.0, Release Notes.

SCO Advanced File and Print Server Release 3.5.2, Administrator's Handbook, Appendix B, "Internetworking with Advanced Server.

RFC 1001, "Protocol Standard for a NetBIOS Service on a TCP/UDP Transport: Concepts and Methods", March 1987.

RFC 1002, "Protocol Standard for a NetBIOS Service on a TCP/UDP Transport: Detailed Specifications", March 1997.

From the Xinuos technical article database, record 100037. Reproduced with permission. The original is at www.sco.com/ta/100037, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.