Wednesday, January 26, 2011

How to configure ldap to resolve host names?

I'm new to LDAP and I already configured accounts with LDAP so I can login on few computers with LDAP.

Now I would like to add some host names to LDAP. In /etc/nsswitch.conf I changed:

hosts:          files dns ldap

But I have no idea how to add anything to LDAP database so it could resolve some names. I tried google but I couldn't find anything helpful.

On example, how to add this:

192.168.1.1    node1
  • I already figured it out with help of migrationtools (ubuntu package).

    First, create file add_hosts.ldif:

    dn: ou=Hosts,dc=example,dc=net
    objectClass: organizationalUnit
    ou: Hosts
    

    Load it with:

    ldapadd -D cn=admin,dc=example,dc=net -W -f add_hosts.ldif
    

    Above steps should be done only once.

    Then create file node1_host.ldif:

    dn: cn=node1,ou=Hosts,dc=example,dc=net
    objectClass: top
    objectClass: ipHost
    objectClass: device
    ipHostNumber: 192.168.1.1
    cn: node1
    cn: n1
    

    I added second cn so it can resolve both node1 and n1. If you want to add another host, just create another file node2_host.ldif and load it into LDAP.

    From klew

0 comments:

Post a Comment