This shows you the differences between two versions of the page.
saisp:labs:02:contents:04 [2013/11/11 00:46] 127.0.0.1 external edit |
saisp:labs:02:contents:04 [2014/03/03 00:27] (current) razvan.deaconescu |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 04. Lorem ipsum ==== | + | ==== 04. [15p] Configurare hostname prin LDAP ==== |
- | ... | + | Modul în care se face interogarea numelor de stații (//hostname//) este descris în ''/etc/nsswitch.conf'', componenta ''hosts''. De obicei se întâmplă prin DNS și prin intermediul fișierului ''/etc/hosts''. Putem adăuga intrări și prin LDAP. |
+ | Configurați suport de LDAP în NSS (//Name Service Switch//) pe stația client astfel încât serverul LDAP să fie accesibil prin numele ''server'', clientul prin numele ''client'' iar sistemul fizic prin numele ''host''. Pentru validare folosiți ''getent'' și ''ping''. | ||
+ | Folosiți pe post de ''dn'' valorile: | ||
+ | * ''cn=server,dc=labs,dc=cs,dc=pub,dc=ro'' | ||
+ | * ''cn=client,dc=labs,dc=cs,dc=pub,dc=ro'' | ||
+ | * ''cn=host,dc=labs,dc=cs,dc=pub,dc=ro'' | ||
+ | |||
+ | Va trebui sa creati fisiere ldif care sa descrie valorile de mai sus, iar apoi sa adaugati intrarile respective in baza de date LDAP. | ||
+ | |||
+ | <note tip> | ||
+ | Urmăriți schema clasei ''ipHost'' descrisă în fișierul ''/etc/ldap/schema/nis.schema'' de pe stația server. | ||
+ | |||
+ | Urmăriți exemplul de configurare de aici: https://wiki.archlinux.org/index.php/LDAP_Hosts | ||
+ | </note> | ||
+ | |||
+ | <solution -hidden> | ||
+ | Pentru început creăm cele trei fișiere LDIF din clasa ''ipHost'' pentru cele trei stații: | ||
+ | <file none cn-server.ldif> | ||
+ | dn: cn=server,dc=labs,dc=cs,dc=pub,dc=ro | ||
+ | cn: server | ||
+ | ipHostNumber: 192.168.0.2 | ||
+ | description: LDAP server | ||
+ | l: EG106 | ||
+ | objectClass: ipHost | ||
+ | objectClass: device | ||
+ | objectClass: top | ||
+ | </file> | ||
+ | <file none cn-client.ldif> | ||
+ | dn: cn=client,dc=labs,dc=cs,dc=pub,dc=ro | ||
+ | cn: client | ||
+ | ipHostNumber: 192.168.0.3 | ||
+ | description: LDAP server | ||
+ | l: EG106 | ||
+ | objectClass: ipHost | ||
+ | objectClass: device | ||
+ | objectClass: top | ||
+ | </file> | ||
+ | <file none cn-host.ldif> | ||
+ | dn: cn=host,dc=labs,dc=cs,dc=pub,dc=ro | ||
+ | cn: host | ||
+ | ipHostNumber: 192.168.0.1 | ||
+ | description: LDAP server | ||
+ | l: EG106 | ||
+ | objectClass: ipHost | ||
+ | objectClass: device | ||
+ | objectClass: top | ||
+ | </file> | ||
+ | |||
+ | Încărcăm cele trei fișiere în baza de date LDAP:<code bash> | ||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ldapadd -D cn=admin,dc=labs,dc=cs,dc=pub,dc=ro -w student -f cn-server.ldif | ||
+ | adding new entry "cn=server,dc=labs,dc=cs,dc=pub,dc=ro" | ||
+ | |||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ldapadd -D cn=admin,dc=labs,dc=cs,dc=pub,dc=ro -w student -f cn-client.ldif | ||
+ | adding new entry "cn=client,dc=labs,dc=cs,dc=pub,dc=ro" | ||
+ | |||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ldapadd -D cn=admin,dc=labs,dc=cs,dc=pub,dc=ro -w student -f cn-host.ldif | ||
+ | adding new entry "cn=host,dc=labs,dc=cs,dc=pub,dc=ro" | ||
+ | </code> | ||
+ | |||
+ | Folosim un editor pentru a actualiza linia ''hosts'' din fișierul ''/etc/nsswitch.conf'' și adăugăm LDAP:<code> | ||
+ | hosts: files ldap mdns4_minimal [NOTFOUND=return] dns | ||
+ | </code> | ||
+ | |||
+ | Pentru a încărca noile configurații repornim NSCD:<code bash> | ||
+ | root@ldap-client:~# service nscd restart | ||
+ | [ ok ] Restarting Name Service Cache Daemon: nscd. | ||
+ | </code> | ||
+ | |||
+ | În final folosim ''getent'' și ''ping'' pentru a valida configurarea corectă:<code bash> | ||
+ | root@ldap-client:~# getent hosts | ||
+ | 127.0.0.1 localhost | ||
+ | 127.0.1.1 ldap-client.labs.cs.pub.ro ldap-client | ||
+ | 127.0.0.1 localhost ip6-localhost ip6-loopback | ||
+ | 192.168.0.2 server | ||
+ | 192.168.0.3 client | ||
+ | 192.168.0.1 host | ||
+ | |||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ping -c 1 client | ||
+ | PING client (192.168.0.3) 56(84) bytes of data. | ||
+ | 64 bytes from client (192.168.0.3): icmp_seq=1 ttl=64 time=0.028 ms | ||
+ | [...] | ||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ping -c 1 server | ||
+ | PING server (192.168.0.2) 56(84) bytes of data. | ||
+ | 64 bytes from server (192.168.0.2): icmp_seq=1 ttl=64 time=0.462 ms | ||
+ | [...] | ||
+ | root@ldap-client:/etc/ldap/ldif/lab-02-solution# ping -c 1 host | ||
+ | PING host (192.168.0.1) 56(84) bytes of data. | ||
+ | 64 bytes from host (192.168.0.1): icmp_seq=1 ttl=64 time=0.152 ms | ||
+ | [...] | ||
+ | </code> | ||
+ | |||
+ | </solution> |