Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:    node1
share|improve this question
up vote 4 down vote accepted

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
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.