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
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • 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
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Configure the Listener
        • SNMPv3
        • Querying the Local Test
        • Firewall and Diagnostics
        • Alternative Implementation

        SNMP

        Synopsis #

        OpenBSD includes snmpd(8) and the snmp(1) client. The base daemon supports SNMPv1, SNMPv2c, and SNMPv3, including authentication and encryption. It exposes system, interface, PF, and supported sensor information; configurable custom OIDs can also permit writes.

        Configure the Listener #

        Create /etc/snmpd.conf before enabling the daemon. With no explicit listener, the daemon listens on all addresses. There is no default community string. SNMPv3 is the default listener protocol; select older protocols explicitly when required.

        For a local SNMPv2c test:

        listen on 127.0.0.1 read snmpv2c
        read-only community "replace-this-community"
        system description "OpenBSD Router"
        system location "Data Center 1"
        system contact "noc@example.org"
        

        SNMPv2c communities are sent in plaintext. Keep this example bound to loopback. For remote monitoring, prefer SNMPv3 with encryption and restrict access with PF.

        SNMPv3 #

        The following alternative uses an address assigned to the monitoring interface. Replace the address and both example secrets before use:

        listen on 192.0.2.1 read snmpv3
        seclevel enc
        user "monitor" auth hmac-sha256 authkey "replace-authentication-secret" enc aes enckey "replace-encryption-secret"
        

        Protect the configuration and validate it before starting:

        doas chmod 600 /etc/snmpd.conf
        doas snmpd -n && doas rcctl enable snmpd
        doas rcctl start snmpd
        

        After editing an active configuration:

        doas snmpd -n && doas rcctl restart snmpd
        

        The service does not support configuration reload. Use the same username, security level, authentication algorithm, and encryption algorithm in the monitoring client. Test both a successful authenticated query and rejection with incorrect credentials.

        Querying the Local Test #

        The base client can query the loopback SNMPv2c configuration:

        snmp get -v 2c -c replace-this-community 127.0.0.1 sysUpTime.0
        snmp walk -v 2c -c replace-this-community 127.0.0.1 system
        

        Walk only the relevant subtree when diagnosing larger agents. The daemon provides its supported MIBs directly; there are no include pf, include interfaces, or sensor temperature configuration directives. Sensor availability depends on the hardware and drivers, and does not require enabling sensorsd merely for SNMP exposure.

        Firewall and Diagnostics #

        Integrate a restricted listener rule into the existing PF policy, adapting the interface and monitoring subnet:

        block in proto udp to port 161
        pass in on em0 inet proto udp from 192.0.2.0/24 to 192.0.2.1 port 161
        

        Check rule ordering against the complete ruleset. Restricting a community does not restrict source addresses; PF supplies that boundary. Do not expose monitoring access indiscriminately to the Internet.

        Inspect daemon messages in /var/log/daemon. For foreground debugging, stop the regular service before running snmpd -dv; restart the regular service afterward. Debug mode is not needed for routine operation.

        Alternative Implementation #

        The net-snmp package provides a separate implementation with its own configuration and extension model. It is not required merely to obtain SNMPv3 on OpenBSD. Avoid running two agents on the same listening address and port, and follow the installed package documentation when selecting that implementation.

        Report a bug
        • Synopsis
        • Configure the Listener
        • SNMPv3
        • Querying the Local Test
        • Firewall and Diagnostics
        • Alternative Implementation