Managing NFS and NIS, 2nd Edition - Mike Eisler [194]
In addition to providing NIS server binding information, ypwhich examines the NIS map information: the master server for a map, the list of all maps, and map nickname translations. Map nicknames are more mnemonic forms of map names used in place of the actual DBM filenames in NIS-related utilities; the nickname usually has the .byaddr or .byname suffix removed. Nicknames exist only within the ypmatch, ypcat, and ypwhich utilities; they are not part of the maps and are not part of the NIS servers. No application will ever perform a key lookup in map passwd; it has to use passwd.byname or passwd.byuid.
ypwhich -x prints the table of nicknames:
% ypwhich -x
Use "passwd" for map "passwd.byname"
Use "group" for map "group.byname"
Use "networks" for map "networks.byaddr"
Use "hosts" for map "hosts.byname"
Use "protocols" for map "protocols.bynumber"
Use "services" for map "services.byname"
Use "aliases" for map "mail.aliases"
Use "ethers" for map "ethers.byname"
Use "ipnodes" for map "ipnodes.byname"
Use "project" for map "project.byname"
While map nicknames provide a shorter command-line option for tools that take a map name as a parameter, they can also create name conflicts with non-standard maps that share commonly used map names. For example, a daemon that maps popular internal resource server names to IP ports might create an NIS map called services advertising its default mappings. This map name will not conflict with the NIS map created from /etc/inet/services because the latter is converted into the map services.byname. Users of ypcat and ypmatch may be surprised by output that appears to confuse the map names.
The following example doesn't work at first because the ypmatch utility turns the map name services into services.byname, using the standard nickname translation. NIS completely ignores the map you want. If you use ypmatch -t, nickname translation is suppressed and you locate the desired map:
% ypmatch cullinet services
Can't match key cullinet in map services.byname. Reason: no such key in map.
% ypmatch -t cullinet services
cullinet 6667
If you create your own maps, it's best to pick names that do not conflict with the standard map nicknames. Finally, ypwhich finds the master server for a map, or prints the list of all known maps if passed the -m option:
% ypwhich -m passwd
mahimahi
% ypwhich -m
excerpt follows
protocols.byname mahimahi
passwd.byuid mahimahi
passwd.byname mahimahi
hosts.byname mahimahi
rpc.bynumber mahimahi
group.bygid mahimahi
netmasks.byaddr mahimahi
hosts.byaddr mahimahi
netgroup mahimahi
group.byname mahimahi
mail.aliases mahimahi
services.byname mahimahi
netgroup.byhost mahimahi
protocols.bynumber mahimahi
ethers.byname mahimahi
bootparams mahimahi
ypservers mahimahi
ypwhich -m examines the NIS master server name embedded in the NIS map DBM file.
You can also explode an NIS map using makedbm -u, which "undoes" a DBM file. You see the data records as well as the two additional records added by DBM containing the NIS master name and the map's timestamp. If you have concerns about data disappearing from NIS maps, dump the entire map (including keys) using makedbm -u:
[wahoo]% cd /var/yp/nesales
[wahoo]% /usr/etc/yp/makedbm -u ypservers
YP_LAST_MODIFIED 0649548751
YP_MASTER_NAME wahoo
wahoo wahoo
redsox redsox
thud thud
The map master information is useful if you have changed NIS master servers and need to verify that client maps are built correctly and synchronized with the new master server.
Setting initial client bindings
The ypinit command is used to preconfigure a list of NIS servers to contact at startup time. ypinit stores the list of NIS servers in the file /var/yp/binding/domainname/ypservers, where domainname resolves to your NIS domain name. Normally, ypinit is run only once after installing the system, though it may also be run whenever a new NIS server is added to the network or an existing one is decommissioned:
# ypinit -c
In order for NIS to operate sucessfully, we have to construct a list of the
NIS servers. Please