Solaris のシステム管理 (ネーミングとディレクトリサービス : FNS、NIS+ 編)

nsswitch.conf テンプレートファイル

Solaris オペレーティング環境では、4 つの nsswitch.conf テンプレートを用意して、異なるネームサービスに対応しています。各テンプレートでは、デフォルトの情報ソース (一次ソース、およびそれに続くソース) として、それぞれ異なる内容が指定されています。

4 つのテンプレートファイルについて説明します。

要件に一番近いテンプレートファイルを nsswitch.conf 構成ファイルにコピーして、必要に応じてファイルを変更します。

たとえば、LDAP テンプレートファイルを使用するには、以下のコマンドを入力します。


mymachine# cp nsswitch.ldap nsswitch.conf

デフォルトスイッチテンプレートファイル

Solaris オペレーティング環境の 4 つのスイッチファイルを、以下に示します。


例 1–1 NIS+ スイッチファイルテンプレート (nsswitch.nisplus)


#
# /etc/nsswitch.nisplus:
# 
# An example file that could be copied over to /etc/nsswitch.conf;
# it uses NIS+ (NIS Version 3) in conjunction with files.
# 
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
# the following two lines obviate the "+" entry in /etc/passwd
# and /etc/group.
passwd: files nisplus
group: files nisplus
# consult /etc "files" only if nisplus is down.
hosts: nisplus [NOTFOUND=return] files
# Uncomment the following line, and comment out the above, to use
# both DNS and NIS+. You must also set up the /etc/resolv.conf
# file for DNS name server lookup. See resolv.conf(4).
# hosts: nisplus dns [NOTFOUND=return] files
services: nisplus [NOTFOUND=return] files
networks: nisplus [NOTFOUND=return] files
protocols: nisplus [NOTFOUND=return] files
rpc: nisplus [NOTFOUND=return] files
ethers: nisplus [NOTFOUND=return] files
netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
publickey: nisplus
netgroup: nisplus
automount: files nisplus
aliases: files nisplus
sendmailvars: files nisplus


例 1–2 NIS スイッチファイルテンプレート


# 
# /etc/nsswitch.nis:
#
# An example file that could be copied over to /etc/nsswitch.conf;
# it uses NIS (YP) in conjunction with files.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
#
# the following two lines obviate the "+" entry in /etc/passwd
# and /etc/group.
passwd: files nis
group: files nis
# consult /etc "files" only if nis is down.
hosts: nis [NOTFOUND=return] files
networks: nis [NOTFOUND=return] files
protocols: nis [NOTFOUND=return] files
rpc: nis [NOTFOUND=return] files
ethers: nis [NOTFOUND=return] files
netmasks: nis [NOTFOUND=return] files
bootparams: nis [NOTFOUND=return] files
publickey: nis [NOTFOUND=return] files
netgroup: nis
automount: files nis
aliases: files nis 
# for efficient getservbyname() avoid nis 
services: files nis 
sendmailvars: files


例 1–3 Files スイッチファイルテンプレート


#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf;
# it does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
passwd: files
group: files
hosts: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files	
bootparams: files
publickey: files
# At present there isn't a 'files' backend for netgroup;
# the system will figure it out pretty quickly, and will notuse
# netgroups at all.
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files


例 1–4 LDAP スイッチファイルテンプレート


#
# /etc/nsswitch.ldap:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# uses LDAP in conjunction with files.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

# the following two lines obviate the "+" entry in /etc/passwd 
and /etc/group.
passwd:     files ldap
group:      files ldap

hosts:      ldap [NOTFOUND=return] files

networks:   ldap [NOTFOUND=return] files
protocols:  ldap [NOTFOUND=return] files
rpc:        ldap [NOTFOUND=return] files
ethers:     ldap [NOTFOUND=return] files
netmasks:   ldap [NOTFOUND=return] files
bootparams: ldap [NOTFOUND=return] files
publickey:  ldap [NOTFOUND=return] files

netgroup:   ldap

automount:  files ldap
aliases:    files ldap

# for efficient getservbyname() avoid ldap
services:   files ldap
sendmailvars:   files

nsswitch.conf ファイル

Solaris の環境を初めてインストールするときのデフォルトの nsswitch.conf ファイルは、Solaris のソフトウェアをインストールする際に選択したネームサービスで決まります。このファイルの各行は、ネットワーク情報の種類 (ホスト、パスワード、グループなど) と、それに対する 1 つ以上の情報源 (NIS+ テーブル、NIS マップ、DNS ホストテーブル、同一ワークステーション上の /etc など) を対応させています。クライアントは、この情報源から各情報を検索します。ネームサービスが選択されると、そのサービスのスイッチテンプレートファイルがコピーされ、新しい nsswitch.conf ファイルが作成されます。たとえば、NIS+ を選択した場合は、nsswitch.nisplus ファイルがコピーされ新しい nsswitch.conf ファイルが作成されます。

/etc/nsswitch.conf ファイルは、Solaris 9 ソフトウェアにより各マシンの /etc ディレクトリに自動的にロードされます。また次の代替テンプレートファイルも作成されます。

これらの代替テンプレートファイルには、それぞれネットワーク情報の情報源として NIS+、NIS、ローカルファイル、 または LDAP を使用する標準的なスイッチ構成が設定されています。Solaris オペレーティング環境をマシンに最初にインストールすると、マシンのデフォルトのネームサービスが NIS+、NIS、ローカルファイル、または LDAP から選択されます。 インストールの途中、選択されたネームサービスに対応するテンプレートファイルが /etc/nsswitch.conf にコピーされます。たとえば、NIS+ を使用するマシンクライアントの場合、インストーラは nsswitch.nisplusnsswitch.conf にコピーします。

特殊な名前空間を持っている場合を除き、通常の操作には nsswitch.conf にコピーされるデフォルトのテンプレートファイルを使用します。