OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Complete the First 30 Minutes After Installation
        • Check Hardware Compatibility Before Installing
        • Bootstrap Wi-Fi Firmware Without Ethernet
        • Set Up OpenBSD as a Laptop or Workstation
        • Configure Laptop Power Management
        • Run OpenBSD as a Virtual Machine Guest
        • Install OpenBSD on a VPS or Cloud Server
        • Install OpenBSD with Full-Disk Encryption
        • Troubleshoot Web Browsers on OpenBSD
        • Create an Administrator Account with doas and SSH Keys
        • Establish a Conservative Security Baseline
        • Manage OpenBSD with Ansible
        • Recover Access and Reset the Root Password
        • Collect OpenBSD Diagnostic Evidence
        • Configure Secure Remote Access with OpenSSH
        • Set Up WordPress on OpenBSD
        • Build Third-Party Software from Ports
        • Use FIDO Security Keys with OpenSSH
        • Build OpenBSD from Source
        • Configure Wi-Fi Roaming and Wired Failover
        • Dual-Boot OpenBSD on a UEFI System
        • Troubleshoot PF, NAT, and Routing
        • Automate OpenBSD Installation with Autoinstall and PXE
        • Route Multiple VLANs with PF
        • Configure a Road-Warrior WireGuard VPN
        • Troubleshoot Package Installation and Update Failures
        • Route IPv6 Networks without NAT
        • Schedule Recurring Maintenance
        • Plan a Docker Workload Migration to OpenBSD
        • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Test OpenBGPD with Two Providers
        • Unlock an Internal Service with an SSH Key
        • Build a Simple Router and Firewall
        • Monitor an OpenBSD System
        • Back Up and Restore an OpenBSD System
        • Configure softraid RAID1
        • Recover an OpenBSD System That Does Not Boot
        • Install Z shell (zsh)
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • YP Master Server Configuration
          • Enabling Required Services
          • Map Creation and Regeneration
        • YP Slave Server Configuration
        • YP Client Configuration
          • Setting the Domain
          • Enabling the Client
          • Verifying Client Operation
          • Enabling YP User and Group Lookups
          • Logging In with YP Accounts
        • Security Considerations
        • Key Files and Tools

        YP (NIS)

        Synopsis #

        YP (Yellow Pages), also known as NIS (Network Information Service), is a simple protocol for sharing configuration databases such as user accounts, group memberships, and hostnames across a trusted local network. OpenBSD includes support for both YP servers and clients in the base system.

        YP is not the same as LDAP:

        • YP is an older, RPC-based system developed by Sun Microsystems.
        • LDAP (Lightweight Directory Access Protocol) is a modern, extensible protocol standardized in RFC 4511.
        • OpenBSD includes YP and the ldapd(8) LDAP server in the base system.

        YP is best suited for small, trusted networks where simplicity is valued over flexibility or cryptographic security. LDAP offers a richer schema model, encryption, and fine-grained access control, and is generally preferred in larger or more security-sensitive environments.

        This chapter explains how to configure OpenBSD as a YP master, YP slave, or YP client.

        YP Master Server Configuration #

        The YP master server maintains the authoritative copy of all YP maps (databases). These maps are generated from files in /etc and served to clients and slave servers.

        The required daemons are:

        • portmap(8) : RPC port mapper
        • ypserv(8) : YP service daemon
        • ypbind(8) : Binds the master to a YP server for client operations

        Enabling Required Services #

        Set the YP domain before initializing the server or starting the YP daemons. The YP domain is separate from the DNS domain. Store it in /etc/defaultdomain for boot and apply it immediately with domainname(1) :

        printf '%s\n' exampledomain | doas tee /etc/defaultdomain
        doas domainname exampledomain
        

        Initialize the master with ypinit(8) :

        doas ypinit -m
        

        The script uses the configured YP domain and prompts for the list of servers. The local master is included automatically. Enter any slave hostnames, one per line, then press Ctrl-D to finish the list and confirm it. With no slaves, press Ctrl-D at the first host prompt.

        Enable and start the services after initialization has created /var/yp/exampledomain:

        doas rcctl enable portmap ypserv ypbind
        doas rcctl start portmap
        doas rcctl start ypserv
        doas rcctl start ypbind
        

        Map Creation and Regeneration #

        The YP maps are built from standard system files using Makefiles. The default source directory is /etc; the DIR variable in /var/yp/exampledomain/Makefile selects it. See Makefile.yp(8) for map settings and the user and group ID ranges included in the maps.

        After initialization, build the maps. Use the same commands to regenerate all maps after changing the source files:

        cd /var/yp
        doas make
        

        The Makefile processes standard maps such as passwd.byname, group.byname, hosts.byname, etc.

        To regenerate the password maps:

        cd /var/yp
        doas make passwd
        

        YP Slave Server Configuration #

        Slave servers receive map updates from the master using ypxfr(8) .

        Set the same YP domain on the slave before initializing it:

        printf '%s\n' exampledomain | doas tee /etc/defaultdomain
        doas domainname exampledomain
        doas ypinit -s yp-master.example.net
        

        Replace yp-master.example.net with the reachable master hostname. Initialization copies its maps to the slave.

        Enable and start required daemons:

        doas rcctl enable portmap ypserv ypbind
        doas rcctl start portmap
        doas rcctl start ypserv
        doas rcctl start ypbind
        

        On the master, add the slave to the ypservers map if it was not included during initialization, then reload ypserv so that it reads the updated server list before the next map push:

        doas ypinit -u
        doas rcctl reload ypserv
        

        The ypservers map is stored in /var/yp/exampledomain/ypservers.db and identifies servers for map distribution; it is not an access control list. Server access restrictions are described in ypserv(8) .

        To fetch a map immediately on the slave:

        doas ypxfr passwd.byname
        

        YP Client Configuration #

        Clients use ypbind(8) to bind to a running YP server and request maps.

        Setting the Domain #

        Ensure /etc/defaultdomain contains the correct YP domain:

        printf '%s\n' exampledomain | doas tee /etc/defaultdomain
        

        Apply immediately:

        doas domainname exampledomain
        

        Enabling the Client #

        The server list /etc/yp/exampledomain can restrict ypbind(8) to specified servers. This is recommended instead of broadcast discovery. Create /etc/yp if needed and place one server hostname per line in the file. These names must be resolvable without YP, for example through DNS or /etc/hosts.

        Enable and start portmap and ypbind:

        doas rcctl enable portmap ypbind
        doas rcctl start portmap
        doas rcctl start ypbind
        

        Verifying Client Operation #

        Use ypwhich(1) to confirm which server is being used:

        ypwhich
        

        Example output:

        yp-master.example.net
        

        To list available maps:

        ypwhich -m
        

        Use ypcat(1) to dump a map and ypmatch(1) to query a key. Replace alice with a user included in the map; default map settings exclude system accounts such as root:

        ypcat passwd.byname
        ypmatch alice passwd.byname
        

        Enabling YP User and Group Lookups #

        OpenBSD does not use /etc/nsswitch.conf for these lookups. Enable YP user inclusion through the password database as documented in passwd(5) . Run vipw(8) :

        doas vipw
        

        Add the following entry after the local accounts in /etc/master.passwd:

        +:*::::::::
        

        On saving, vipw checks the file and rebuilds the password databases and /etc/passwd. Do not edit the generated /etc/passwd directly.

        To include YP groups, edit /etc/group with doas vi /etc/group and add this final line, as described in group(5) :

        +:*::
        

        These entries include all users and groups from the corresponding maps. The manuals also describe selecting or excluding individual entries. Exclusions must precede the inclusions they restrict. Group membership requires consistent group.byname, group.bygid, and netid.byname maps.

        Before enabling YP group lookups, configure netid(5) entries for local accounts that must remain usable when YP is unavailable. A local password entry alone does not prevent login from waiting for unavailable YP group information.

        Logging In with YP Accounts #

        Users from YP maps can log in normally. Check that they have home directories and suitable login shells. If home directories are exported over NFS or provisioned on demand, this must be handled separately.

        Verify a YP account through the system lookup routines:

        id alice
        

        To list users in the password map:

        ypcat passwd.byname | cut -d: -f1
        

        Security Considerations #

        YP does not encrypt its network traffic, including transmitted password hashes. For this reason:

        • OpenBSD uses master.passwd.byname and master.passwd.byuid for full password records. Clearing UNSECURE in the domain Makefile excludes hashes from the public passwd.* maps when they are rebuilt; it does not encrypt YP traffic. See Makefile.yp(8) for compatibility details.
        • Restrict server selection with /etc/yp/exampledomain, and limit server access using ypserv(8) , pf(4) , and network segmentation.
        • Do not run YP over untrusted or public networks.

        SSH protects login traffic but does not protect YP queries between clients and servers.

        Key Files and Tools #

        PathPurpose
        /etc/defaultdomainStores the YP domain name
        /var/ypContains YP maps
        /var/yp/exampledomain/ypservers.dbMap of servers for the YP domain
        /etc/yp/exampledomainRestricts the client’s server search
        /etc/master.passwdLocal accounts and YP user inclusions; edit with vipw
        /etc/groupLocal groups and YP group inclusions
        /etc/netidLocal group lookup records for use during YP outages
        CommandDescription
        ypinit -mInitialize YP master server
        ypinit -sInitialize YP slave server
        ypcatView contents of a map
        ypmatchQuery a map for a key
        ypwhichShow the bound YP server
        make (in /var/yp)Rebuild YP maps
        Report a bug
        • Synopsis
        • YP Master Server Configuration
          • Enabling Required Services
          • Map Creation and Regeneration
        • YP Slave Server Configuration
        • YP Client Configuration
          • Setting the Domain
          • Enabling the Client
          • Verifying Client Operation
          • Enabling YP User and Group Lookups
          • Logging In with YP Accounts
        • Security Considerations
        • Key Files and Tools