5.8 Managing Name Services Using the Nsswitch.conf File

In NetWare, each application or NetWare Loadable Module™ (NLM) controls how the server communicates with the network to resolve names.

In NetWare 6, Support Pack 1 or later, rather that letting the application have total control of your server communications, you can now use the nsswitch.conF file to control how an NLM looks up name information in varying databases such as hosts, protocols, and WSNS (WinSock Naming Services). Each database comes from a source such as local files, DNS, and SLP, and you can specify the order in which to look up information in nsswitch.conf.

Most Novell® applications use WinSock for naming and they will automatically use nsswitch.conf. All other NLM programs must be programmed to take advantage of this file. Each NLM must read and interpret the file and extract the information it needs. Developers need to add Sources and Databases to this document as they are implemented by NLM programs for reference by other users.

WSNS is the WinSock Naming Services database. WSNS is not a physical database, but it includes all name service providers available through WinSock on NetWare.

5.8.1 Editing the Nsswitch.conf File

In NetWare 6 Support Pack 1 or later, a sample nsswitch.conf file is in the sys:etc and sys:etc\samples directories. To use this file, you need to edit the sample file in the sys:etc directory on each of your servers.

You can edit the nsswitch.conf with a text editor. If you use the EDIT utility in NetWare, the filename will appear truncated as nsswit~1.con but will save correctly as nsswitch.conf.

In the nsswitch.conf file content, you need to include databases, sources, and criteria.

Databases

The term database is just a logical term referring to a set of name services. Sources refer to the ways in which information can be retrieved for each database, and the criteria allows the administrator to choose an action based on the success or failure of a search.When editing the nsswitch.conf file, use the parameters in the following tables.

This table lists some databases you can use and the functions that use them.

Database

Function Used By

Hosts

  • gethostbyname

  • WSALookupServiceBegin

  • WSALookupServiceNext for the NS_DNS namespace

Protocols

getprotobyname

Services

  • getservbyname

  • getservbyport

WSNS

  • WSALookupServiceBegin

  • WSALookupServiceNext

Sources

For each database, you need to list the sources where information can be found.

The Hosts database can use two sources: files and dns.

The WSNS database can use four sources: dns, slp, sap, and nds.

NetWare can use the following sources:

Source

Description

files

Local files, such as sys:etc\hosts, sys:etc\protocols.

DNS

Domain Name System

SLP

Service Location Protocol

NDS

Novell Directory Services®

SAP

Service Advertising Protocol for IPX™

Following are two scenarios of server setups and how you might want to configure the sources in nsswitch.conf.

Scenario 1

The server is running a Web Server.

Hosts: dns files
WSNS: dns slp

In this scenario, names will always be looked for first in DNS, then in the local hosts file, and finally in SLP.

Scenario 2

Most print applications use SLP and SAP to locate services, so servers in a printing shop might have a file that looks like this:

Hosts: dns files
WSNS: slp sap dns

In this scenario, names will be looked for first in SLP and SAP before looking for names in DNS.

Criteria

The following status codes can be returned:

Status

Description

Success

The requested entry was found.

Notfound

The entry is not present at this source.

Tryagain

The source is busy and might not respond.

Unavail

The source is not responding or the entry is corrupt.

For each status, one of two actions is possible:

Action

Description

Continue

Try the next source

Notfound

Return with the current result

File Format Guidelines

When formatting the file, use the following guidelines:

  • In the file, use the following syntax:

    <entry>

    :=

    <database> ":" [<sources> [<criteria>]]*

    <criteria>

    :=

    "[" <criterion>+ "]"

    <criterion>

    :=

    <status> "=" <action>

    <status>

    :=

    "success" | "notfound" | "unavail" | "tryagain"

    <action>

    :=

    "return" | "continue"

  • Start each entry on a new line in the file.

  • Use a pound sign (#) to delimit comments to the end of the line.

    NOTE:Blank lines are ignored and all entries are case insensitive.

  • For each entry, include a database name terminated with a colon (:) and a space delimited list of sources.

  • For each source, you can have an optional trailing criterion that determines whether the next listed source is used or the search terminates at the current source.

  • For each criterion, include at least one status code and the action to take if that status code occurs.

Example File

The following is an example of the contents of an nsswitch.conf file:

hosts: files dns
WSNS: dns slp [success=return] sap

In the first line of this example, the hosts database determines how NetWare will resolve names for DNS. The files source for this database refers to the sys:etc\hosts file. In this statement, DNS queries must first try to resolve names in the files source. If that is unnecessarily, then it tries the dns source.

The second line is for the WSNS (WinSock Name Service) database. Unlike the hosts database, which by default will return as soon as a successful query has been returned, the WSNS database always goes on to the next source unless otherwise directed. So in this example, WSNS queries first try DNS, and then SLP. After the SLP source, there is a criteria that specifies that if SLP does succeed, do not go on to the next source (in this case, SAP).

For the SLP and SAP sources, success is defined to be the return of one or more names from a query. WinSock allows for the enumeration (discovering) of name types, such as file server and print servers. Novell eDirectory™ 8.7.3(NDS) and other applications often try to locate all services of a specific type, so it is important for you to configure the nsswitch.conf file to allow the enumeration to happen as needed.

The list of sources for each database is exclusive. In other words, if it is not on the list, the source will not be searched.

In the following example, DNS name lookup is allowed only in the local file.

Hosts: files

In the next example, lookup for names is only allowed in DNS and SLP.

WSNS: dns slp

If your network has both TCPIP and IPX, make sure that all servers with both protocols configured have both SAP and SLP in the source list for the WSNS database or you might lose connectivity.