Signal9Signal9 — home
online
all lessons

LPIC-2 Network Client Management: DHCP, PAM, and LDAP

Advanced40 min6 steps
What you'll learn
  • Configure an ISC DHCP server with subnet/range pools and MAC-keyed fixed-address reservations, and explain why only one authoritative server may serve a broadcast domain
  • Read a PAM stack by its four management groups (auth/account/password/session) and reason about the control flags required/requisite/sufficient/optional — without locking yourself out
  • Describe how OpenLDAP slapd serves a DN-addressed directory and manage entries with LDIF via ldapadd/ldapsearch/ldapmodify, integrating clients through sssd
  • Explain why every LDAP deployment must use TLS (ldaps/StartTLS) and what plaintext LDAP leaks
  1. The shape of network client management

    Frame the three services as the answer to one question: how does a new machine and its user get an identity on the network?

    Picture a laptop that just plugged into the office network. Before anyone can log in to it, three separate questions have to be answered, and LPIC-2 topic 210 is really these three questions wearing different hats:

    • "What is my address?" — answered by DHCP, which hands out IP addresses automatically.
    • "Is this person allowed to log in, and how do we check?" — answered by PAM, the pluggable framework every login path runs through.
    • "Who is this person, centrally?" — answered by LDAP, a shared directory of users and groups so you don't recreate every account on every box.

    Think of arriving at a large hotel. The front desk assigns you a room number the moment you arrive (DHCP). Your keycard is checked at every door by the same lock mechanism, no matter which door (PAM). And the hotel's guest registry in the back office knows who you are across the whole property, so the spa and the restaurant don't each need their own copy of your details (LDAP).

  2. DHCP: handing out addresses with dhcpd.conf

    Read and write the two things dhcpd.conf does — pools and reservations — and know which to use when.

    The ISC DHCP server (dhcpd) leases IP addresses to clients that ask for one. Its entire behaviour lives in `/etc/dhcp/dhcpd.conf`, and that file does just two jobs:

    • Pools — a subnet block with a range says "any client on this network may borrow an address from this band." This is the dynamic, anonymous case: a guest laptop, a phone, a printer you don't care to name.
    • Reservations — a host block with fixed-address ties a specific IP to a specific client, identified by its MAC address. This is the static case: the office printer that scripts hardcode, a server that DNS points at.

    Analogy: the range is general admission seating — sit anywhere that's free. A reservation is a named seat with your name taped to it; it's yours whether you show up or not.

    Runnable in the netsvc-dhcp-reservation room — that room’s setup plants the files it reads

    cat /etc/dhcp/dhcpd.conf
    # Authoritative for this segment
    authoritative;
    default-lease-time 600;
    max-lease-time 7200;
    
    subnet 192.0.2.0 netmask 255.255.255.0 {
      range 192.0.2.100 192.0.2.200;
      option routers 192.0.2.1;
      option domain-name-servers 192.0.2.53;
    }
    
    host laserjet {
      hardware ethernet 52:54:00:ab:cd:ef;
      fixed-address 192.0.2.10;
    }
    range
    The band of addresses leased dynamically to any client on this subnet.
    fixed-address
    The single address always given to the matching host (must be outside the range).
    hardware ethernet
    The client's MAC address — the key that matches a request to a host reservation.
    option routers / domain-name-servers
    Extra settings (gateway, DNS) pushed to the client along with its lease.
    The subnet block defines the pool: clients on 192.0.2.0/24 get a dynamic address somewhere in .100-.200, plus a gateway (option routers) and DNS server pushed to them automatically. The host laserjet block is a reservation: whenever the NIC with MAC 52:54:00:ab:cd:ef asks, it always receives 192.0.2.10 — note that address sits outside the dynamic range so the two never collide. authoritative; is the critical line covered in the next callout.

    Check yourself

    You need the office printer (a fixed MAC) to always get 192.0.2.10. Which dhcpd.conf construct gives a specific client a specific IP keyed by its MAC?

  3. PAM: the four groups and the control flags

    Decode a /etc/pam.d stack into its management groups and control flags so you can read what a login actually checks.

    PAM (Pluggable Authentication Modules) is the layer every login path — login, sshd, sudo, su — calls instead of checking passwords itself. That's the power of it: change the PAM rules once and every login program inherits the new policy.

    Each service has a file in `/etc/pam.d/` built from stacked lines. Every line names one of four management groups — the phases of a login:

    • auth — prove you are who you say (password, key, token).
    • account — are you allowed right now? (account expired? wrong time of day? login disabled?)
    • password — the rules for changing a credential (complexity, history).
    • session — set up and tear down the session itself (mount home dir, write the log, set limits).

    Think of the four groups as airport checkpoints in order: auth = show your passport, account = is your visa still valid, password = renew the passport if it expired, session = the gate agent seats you and logs the boarding.

    cat /etc/pam.d/sshd 2>/dev/null | head
    #%PAM-1.0
    auth       required     pam_securetty.so
    auth       requisite    pam_nologin.so
    auth       sufficient   pam_unix.so nullok
    auth       optional     pam_motd.so
    account    required     pam_unix.so
    session    required     pam_limits.so
    required
    Must pass for the group to succeed, but the stack keeps running — failure is recorded and reported at the end (doesn't reveal which module failed).
    requisite
    Must pass; failure stops the stack IMMEDIATELY and returns. Like required but fails fast.
    sufficient
    If it passes (and nothing required before it failed), the group succeeds right now and later modules are skipped.
    optional
    Its result only matters if it's the only module in the group; otherwise ignored. Used for nice-to-haves like showing a message.
    Read each line as group → control flag → module. The first column is the management group (auth/account/session here); the second is the control flag that decides how its result feeds the verdict; the third is the module doing the work. The four control flags in this stack are exactly the ones the exam drills, explained next.

    Check yourself

    In a PAM stack, which control flag makes the group succeed immediately on a pass and skip the remaining modules in that group (assuming nothing required already failed)?

  4. OpenLDAP: a directory addressed by DN

    Understand what slapd serves and manipulate entries with LDIF using the ldap* client tools.

    OpenLDAP's server daemon is `slapd`. It serves a directory: a tree of entries about people, groups, and machines that many systems can share, so you define a user once centrally instead of running useradd on fifty boxes.

    Every entry has a Distinguished Name (DN) — its full, unique address read from the leaf up to the root, like uid=jdoe,ou=people,dc=example,dc=com. That reads right-to-left as a path: within domain example.com, organisational unit people, the user jdoe.

    Analogy: a DN is a postal address written inside-out — name, then street, then city, then country. Each component narrows down exactly one entry in the tree, the same way uid=jdoe narrows within ou=people narrows within dc=example,dc=com.

    You rarely edit the database files directly. Instead you describe changes in LDIF (LDAP Data Interchange Format) — a plain-text record of an entry's attributes — and feed it to the client tools.

    Example — not runnable on your lab box

    ldapsearch -x -H ldap://dir.example.com -b 'dc=example,dc=com' '(uid=jdoe)'
    # jdoe, people, example.com
    dn: uid=jdoe,ou=people,dc=example,dc=com
    objectClass: inetOrgPerson
    uid: jdoe
    cn: Jane Doe
    mail: jdoe@example.com
    
    # search result
    search: 2
    result: 0 Success
    -x
    Use simple authentication instead of SASL — fine for a quick anonymous or bind query.
    -H
    The LDAP URI of the server to contact (ldap:// here; we switch this to ldaps:// in the next step).
    -b
    Base DN: the point in the tree to start searching from.
    ldapsearch reads the directory. The result is one entry identified by its dn, followed by its attributes (uid, cn, mail). The (uid=jdoe) part is an LDAP filter; -b sets the base DN (the subtree to search under). This is the read half of directory management.

    Example — not runnable on your lab box

    ldapadd -x -D 'cn=admin,dc=example,dc=com' -W -f newuser.ldif
    Enter LDAP Password:
    adding new entry "uid=asmith,ou=people,dc=example,dc=com"
    -D
    Bind DN: the directory identity you connect as (needs permission to write).
    -W
    Prompt for the bind password interactively rather than putting it on the command line.
    -f
    Read the change from this LDIF file instead of stdin.
    ldapadd creates entries from an LDIF file. -D is the bind DN — the directory account you authenticate as (here the admin) — and -W prompts for that account's password. Its siblings: ldapsearch reads, ldapadd creates, ldapmodify changes existing entries (also from LDIF), ldapdelete removes them. Together they are the full lifecycle, all driven by LDIF.

    Check yourself

    What is the term for an entry's full, unique address in an LDAP directory, e.g. uid=jdoe,ou=people,dc=example,dc=com?

  5. Secure LDAP with TLS — always

    Understand what plain LDAP leaks and how ldaps / StartTLS closes the hole.

    Here is the single most important operational fact about LDAP: a plain `ldap://` simple bind sends the bind DN's password across the network in cleartext. Anyone who can sniff the segment — a malicious switch port, a compromised host, an attacker on the same Wi-Fi — reads your directory admin password straight off the wire.

    Because LDAP is the authentication backbone, that one captured password often unlocks the whole identity system. So TLS is not a hardening nicety here; it's the baseline.

    There are two ways to wrap LDAP in TLS:

    • ldaps:// — TLS from the first byte, on the dedicated port 636. The whole conversation is encrypted before any bind happens.
    • StartTLS — connect on the normal port 389, then issue a STARTTLS command to upgrade the existing connection to TLS before binding.

    Analogy: plain LDAP is shouting your password across a crowded room. ldaps/StartTLS is stepping into a soundproof booth first, then talking.

    Example — not runnable on your lab box

    ldapsearch -x -H ldaps://dir.example.com -b 'dc=example,dc=com' '(uid=jdoe)'
    dn: uid=jdoe,ou=people,dc=example,dc=com
    uid: jdoe
    cn: Jane Doe
    
    result: 0 Success
    -H ldaps://
    Connect with implicit TLS on port 636 — encrypted from the first byte.
    -ZZ
    (Alternative) Issue StartTLS on the normal port and FAIL if the upgrade isn't successful — never silently fall back to cleartext.
    Identical query to before, but the -H URI is now `ldaps://` — the entire exchange, including the bind password, travels encrypted on port 636. Compare to the previous step's ldap://: same result, but a sniffer now sees only ciphertext. For the StartTLS variant you'd keep ldap:// and add -ZZ, which requires the connection be upgraded to TLS before continuing.

    Check yourself

    Which protection prevents an LDAP simple bind password from being readable by a network sniffer?

  6. Try it in your live terminal

    Inspect the PAM and account plumbing on the real sandbox — read-only, so it's safe even if the server services aren't installed.

    You have a real root shell to your right. The DHCP, LDAP, and slapd servers may not be installed on this box — they're services you'd add deliberately — so these commands are pure inspection: they read what's already there and never change a thing. Run them in order and connect each back to a concept above.

    ls /etc/pam.d/ | head
    Every login-aware program that uses PAM has a policy file here. Each name (sshd, login, sudo, su, ...) is a service whose auth/account/password/session stack you could read — proof of how many paths PAM sits in front of at once.
    cat /etc/pam.d/sshd 2>/dev/null | head
    Read a real stack: first column = management group, second = control flag, third = module. Find a sufficient and a required line and predict how each affects the verdict. (The 2>/dev/null quietly absorbs the error if sshd's PAM file isn't present.)
    getent passwd root
    getent queries the same NSS sources a login does — local files plus any directory (LDAP via sssd) wired in. root always resolves locally, so this is a safe smoke test of name resolution; on an LDAP-integrated box, a directory user would resolve the same way through sssd.
Recap
  • DHCP, PAM, and LDAP answer one question between them — how a new machine and its user gain a working identity on the network (address, login check, central account).
  • In dhcpd.conf, subnet/range lease addresses dynamically while host/fixed-address pin a MAC to one IP — and only one authoritative server may serve a broadcast domain, or clients race for conflicting leases.
  • A PAM stack is four management groups (auth/account/password/session) gated by control flags (required/requisite/sufficient/optional); a bad edit locks out every login, so keep an open root shell while testing.
  • OpenLDAP slapd serves a DN-addressed tree managed with LDIF via ldapadd/ldapsearch/ldapmodify, consumed by clients through sssd — and it must run over TLS (ldaps/StartTLS) because plain LDAP sends bind passwords in cleartext.
Service → what it does / how it's managed / the trap
ServiceManagesKey tool/fileClassic trap
DHCP (dhcpd)Auto IP leases & reservations/etc/dhcp/dhcpd.conf (subnet/range, host/fixed-address)Two authoritative servers on one segment — clients race for leases
PAMEvery login's auth/account/password/session policy/etc/pam.d/* (groups + required/requisite/sufficient/optional)A bad edit locks out all logins — keep a root shell open
OpenLDAP (slapd)A shared DN-addressed user/group directoryldapadd/ldapsearch/ldapmodify + LDIF; clients via sssdPlain ldap:// leaks the bind password — require TLS
TLS for LDAPEncrypting the directory conversationldaps:// (636) or StartTLS / -ZZ (389)Trusting the internal network and skipping TLS