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
        • 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
        • Kernel Parameters with sysctl
          • Common Examples
        • Console Input and Display with wsconsctl
          • Keyboard Layout and Behavior
          • Console Font Configuration
        • Managing Services with rcctl
        • Persistent System Configuration Files
          • Editing User and Group Databases
          • Using /etc/examples
        • Login Classes and Resource Limits
        • Bootloader Configuration
        • Root Mail and Internal Notifications
        • Alternate Root Partition (/altroot)
        • Scheduling Automatic Updates

        System Configuration

        Synopsis #

        System configuration in OpenBSD relies on a small set of well-defined utilities and text files located in /etc. Settings can be applied at runtime using tools like sysctl, wsconsctl, and rcctl, or persisted across reboots in files such as /etc/sysctl.conf, /etc/wsconsctl.conf, and /etc/rc.conf.local. In addition, system maintenance includes managing service behavior, login environment limits, bootloader parameters, root mail notifications, and scheduled updates.

        Kernel Parameters with sysctl #

        The sysctl utility displays and modifies kernel state variables. These variables control aspects such as networking, security, hardware behavior, memory limits, and process constraints.

        To display all values:

        sysctl
        

        To read or set a single value:

        sysctl hw.smt
        doas sysctl hw.smt=0
        

        Save only the settings the host needs in /etc/sysctl.conf. These are examples, not a list to apply in full; enable forwarding only on a router:

        hw.smt=0
        net.inet.ip.forwarding=1
        kern.maxfiles=16384
        net.inet.tcp.recvspace=65536
        net.inet.tcp.sendspace=65536
        kern.nosuidcoredump=1
        vm.swapencrypt.enable=1
        

        Common Examples #

        • hw.smt=0 — Disable hyperthreading (SMT), often recommended for security.
        • net.inet.ip.forwarding=1 — Enable IP packet forwarding for routing.
        • kern.maxfiles — Increase the number of open file descriptors.
        • vm.swapencrypt.enable=1 — Encrypt data swapped to disk.
        • kern.nosuidcoredump=1 — Prevent core dumps for set-user-ID binaries.

        Changes to /etc/sysctl.conf are applied at boot by the system startup scripts.

        Console Input and Display with wsconsctl #

        The wsconsctl utility modifies the behavior of the console keyboard and display. Settings can be applied at runtime or saved in /etc/wsconsctl.conf for persistence.

        Keyboard Layout and Behavior #

        To adjust the keyboard layout:

        doas wsconsctl keyboard.layout=us
        

        Other settings include:

        doas wsconsctl keyboard.bell.volume=0
        doas wsconsctl keyboard.repeat.del1=400
        doas wsconsctl keyboard.repeat.deln=40
        

        To keep keyboard settings after reboot, add them to /etc/wsconsctl.conf:

        keyboard.layout=us
        keyboard.bell.volume=0
        keyboard.repeat.del1=400
        keyboard.repeat.deln=40
        

        Console Font Configuration #

        wsfontload(8) loads bitmap fonts when the display driver supports it. List available loaded fonts with:

        doas wsfontload -l
        

        The manual’s VGA example loads an 8-pixel-high IBM-encoded font:

        doas wsfontload -N myname -h 8 -e ibm /usr/share/misc/pcvtfonts/vt220l.808
        

        Select a supported font through wsconsctl display.font. Font availability and usable dimensions depend on the console driver. wsfontload -f selects a control device, not a font file; the font filename is the final operand. Test console changes before adding them to /etc/rc.local.

        Managing Services with rcctl #

        OpenBSD uses rcctl to enable, disable, and control services. These services are defined under /etc/rc.d/.

        To enable a service at boot:

        doas rcctl enable ntpd
        

        To start a service immediately:

        doas rcctl start ntpd
        

        To check its status:

        doas rcctl check ntpd
        

        To disable a service:

        doas rcctl disable ntpd
        

        To restart a service:

        doas rcctl restart ntpd
        

        To set runtime flags for a service:

        doas rcctl enable ntpd
        doas rcctl set ntpd flags -v
        

        These settings are saved in /etc/rc.conf.local and used on the next service start or restart. The example enables verbose logging; inspect existing flags before replacing them.

        Persistent System Configuration Files #

        System behavior is primarily defined by configuration files in /etc. Below is a summary of key files:

        • /etc/rc.conf — Default system settings (do not edit)
        • /etc/rc.conf.local — Local overrides for services and variables
        • /etc/hostname.if — Interface configuration (e.g., hostname.em0)
        • /etc/myname — System hostname
        • /etc/mygate — Default route (gateway)
        • /etc/resolv.conf — DNS resolver configuration
        • /etc/fstab — Filesystem mounting configuration
        • /etc/doas.conf — Permissions for privilege elevation
        • /etc/login.conf — User login classes and limits
        • /etc/sysctl.conf — Kernel parameters
        • /etc/wsconsctl.conf — Console and keyboard settings
        • /etc/ttys — Terminal and console definitions
        • /etc/mail/aliases — Email aliasing, including for root
        • /etc/rc.local — Startup commands

        Editing User and Group Databases #

        To safely edit the password and user database:

        doas vipw
        

        This ensures updates are atomic and that related shadow files are kept in sync. For group modifications, edit /etc/group directly with a text editor.

        Using /etc/examples #

        When installing or enabling new components, configuration templates are often found in /etc/examples. For example:

        doas cp /etc/examples/ntpd.conf /etc/ntpd.conf
        

        These defaults are maintained by the system and are safe to copy and customize.

        Login Classes and Resource Limits #

        The /etc/login.conf file defines environment and resource limits for user classes. Each user is associated with a class (e.g., default, staff, daemon).

        Example definition:

        staff:\
          :openfiles-cur=1024:\
          :stacksize-cur=8M:\
          :tc=default:
        

        After editing the file, rebuild the capability database:

        doas cap_mkdb /etc/login.conf
        

        Changes take effect at the next login.

        Bootloader Configuration #

        Bootloader behavior is controlled through /etc/boot.conf. This file can contain commands that are automatically passed to the bootloader during early system startup.

        Example configuration:

        set timeout 5
        set image /bsd
        

        This sets a 5-second delay and instructs the loader to boot /bsd. At boot time, users may interrupt the countdown and issue commands manually. Refer to boot(8) for boot prompt syntax.

        Root Mail and Internal Notifications #

        OpenBSD uses local mail delivery to notify administrators about system events. Sources of mail include:

        • cron(8) job output
        • daily(8), weekly(8), and monthly(8) reports
        • Errors or messages from system daemons

        To view root’s mail:

        doas mail
        

        To forward root’s mail to an external address, edit /etc/mail/aliases:

        root: admin@example.com
        

        Then run:

        doas newaliases
        

        Mail is stored in /var/mail/root.

        Alternate Root Partition (/altroot) #

        The daily maintenance script can copy the root partition to a designated /altroot partition. It requires ROOTBACKUP=1 in /etc/daily.local, an existing /altroot directory, and an fstab entry with type ffs and options xx. The destination remains unmounted during the copy and must be large enough for the source.

        This is a partition-image copy, not a directory in which to store a dump archive. Follow Back Up and Restore an OpenBSD System for setup and independent backups.

        Scheduling Automatic Updates #

        Periodic checks can report available security patches without installing them. One way to do this is to add commands to /etc/daily.local, which is run by the daily script.

        Example:

        File: /etc/daily.local

        #!/bin/sh
        syspatch -c
        

        The daily script sources this file; an exit command would terminate the remaining daily maintenance. Keep it owned by root and not writable by other users. Execute permissions are not required. This example checks for patches; installation remains a separate maintenance action.

        System scripts also generate logs in /var/log/:

        • /var/log/daily.out
        • /var/log/weekly.out
        • /var/log/monthly.out

        These logs are emailed to root. Ensure they are reviewed regularly or redirected.

        Report a bug
        • Synopsis
        • Kernel Parameters with sysctl
          • Common Examples
        • Console Input and Display with wsconsctl
          • Keyboard Layout and Behavior
          • Console Font Configuration
        • Managing Services with rcctl
        • Persistent System Configuration Files
          • Editing User and Group Databases
          • Using /etc/examples
        • Login Classes and Resource Limits
        • Bootloader Configuration
        • Root Mail and Internal Notifications
        • Alternate Root Partition (/altroot)
        • Scheduling Automatic Updates