LDAP ホスト

提供: ArchWiki
ナビゲーションに移動 検索に移動

関連記事

この文章では LDAP サーバーに etc/hosts を配置する方法を説明します。まずは LDAP サーバーをセットアップして立ち上げてください (LDAP 認証を参照)。それから /etc/hosts から適切な ldif ファイルを作成します。例:

127.0.0.1 localhost
192.168.1.1 gojira.marex.local gojira
192.168.1.50 gamera.marex.local gamera
192.168.1.51 iris.marex.local iris
192.168.1.52 zedan.marex.local zedan

127.0.0.1 はローカルホスト、192.168.1.1 は LDAP サーバーで、後の3つはワークステーションです (gamera, iris, zedan)。ldif ファイルには ou を作成する必要があります (以下のファイルを hosts.ldif として保存します):

dn: ou=Hosts,dc=marex,dc=local                                                                                              
objectClass: organizationalUnit                                                                                             
objectClass: top                                                                                                            
ou: Hosts

dn: cn=gojira+ipHostNumber=192.168.1.1,ou=Hosts,dc=marex,dc=local
objectClass: ipHost
objectClass: device
objectClass: top
cn: gojira
ipHostNumber: 192.168.1.1

dn: cn=gamera+ipHostNumber=192.168.1.50,ou=Hosts,dc=marex,dc=local
objectClass: ipHost
objectClass: device
objectClass: top
cn: gamera
ipHostNumber: 192.168.1.50

dn: cn=iris+ipHostNumber=192.168.1.51,ou=Hosts,dc=marex,dc=local
objectClass: ipHost
objectClass: device
objectClass: top
cn: iris
ipHostNumber: 192.168.1.51

dn: cn=zedan+ipHostNumber=192.168.1.52,ou=Hosts,dc=marex,dc=local
objectClass: ipHost
objectClass: device
objectClass: top
cn: zedan
ipHostNumber: 192.168.1.52

そして LDAP サーバーにファイルを配置してください:

$ ldapadd -x -W -D 'cn=ldapadmin,dc=marex,dc=local' -h 192.168.1.1 -p 389 -f hosts.ldif
...
adding new entry "cn=zedan+ipHostNumber=192.168.1.52,ou=Hosts,dc=marex,dc=local"

全てが完了したら /etc/nss_ldap.conf を編集して nss_base_hosts から始まる行を以下のように変更します:

nss_base_hosts          ou=Hosts,dc=marex,dc=local?one

localhost と LDAP サーバー、存在するワークステーションについて /etc/hosts を変更してください。以下は gamera ワークステーションでの例です:

127.0.0.1 localhost
192.168.1.1 gojira.marex.local gojira
192.168.1.50 gamera.marex.local gamera

LDAP サーバーではワークステーションは無視してかまいません。最後に /etc/hosts の hosts エントリを編集:

hosts:          files dns ldap

設定をテスト:

$ getent hosts
127.0.0.1       localhost
192.168.1.1     gojira.marex.local gojira
192.168.1.50    gamera.marex.local gamera
192.168.1.1     gojira
192.168.1.50    gamera
192.168.1.51    iris
192.168.1.52    zedan

最初の3行は /etc/hosts 由来で、後の4行は LDAP サーバー由来です。最後に LDAP に ping が通るか確認してください:

$ ping iris
PING iris (192.168.1.51) 56(84) bytes of data.
...