Skip to content

Snippets

Snippets are the smallest unit of NetDefense configuration. Each one targets a single OPNsense concept — a rule, an alias, a group, a user, a host override — and ships its content as a JSON document the agent merges into the device’s config. Templates collect snippets; snippets stand on their own. The concept overview lives in Snippets.

NDWeb Snippets list for ocp-detroit with type, priority, and timestamp filters

The table shows every snippet in the active organization with its type, priority (lower = applied first within its type), and creation/update timestamps. The filter bar above supports a type dropdown, a name regex, a priority comparator (e.g. <500), and date ranges for created/updated.

Each row’s menu has Edit, Duplicate, and Delete; click the name to open the detail editor.

NDWeb Create Snippet page with the type picker, metadata fields, and an empty JSON editor

+ Create Snippet in the top-right opens the create form. You pick:

  • Type — Rule, Alias, Group, User, Host Override, Unbound DNS host, etc. The type decides the JSON schema the agent expects.
  • Name — must be unique within its type in the organization.
  • Priority — integer that orders this snippet relative to others of the same type inside a template. Lower wins.
  • Description — optional free text.

The lower half of the page is a Monaco-style JSON editor with NetDefense’s schema loaded — keys autocomplete, the Valid JSON badge in the gutter flips red the moment you break syntax, and Insert Variable drops in a {{var_name}} reference at the cursor.

NDWeb snippet detail page for "rule_test_2" with metadata and a JSON content editor

The detail page reopens the same editor against an existing snippet. Snippet Information edits the metadata; the Content card edits the JSON body. Save Changes persists the edit — it does not push the snippet to any device. The next time you sync a device that uses a template containing this snippet, the new content is bundled into the computed configuration.

Use Format (top-left of the editor) to pretty-print, Insert Variable to inject a variable reference, and Cmd+F / Ctrl+F for in-document search. The fold arrows on the gutter collapse nested objects so you can focus on one branch at a time.