Skip to main content

NetBox Capirca Plugin

This plugin tries to implement a simple abstraction for Access Control Lists (ACLs) in NetBox by leveraging the capirca ACL abstraction.

ACLs are generated from multiple data sources.

  • a directory that contain static network and service definitions
  • jinja2 templates for policies
  • per ACL network and service definitions
  • terms that are put into the policy template

ACLs can either exist on their own or can be assigned to interfaces, either as ingress or egress ACL. ACLs can be rendered with the capirca generators. Currently only Cisco IOS and IOS XR are supported. If you need more, just add an issue. Supporting an other generator is relativly easy.

Screenshots

ACL Overview ACL edit ACL error ACL rendered Interface Assignment

Installation

Install the package in your NetBox environment. How to do this depends on the way you have build your NetBox environment.

The easiest way is probably the installation via pip:

pip install netbox_capirca_plugin

Create a directory for your capirca network and service definitions and policy templates.

Compatibility

To be compatible with NetBox 3 version 2 of this plugin is required. Version 1 only supports NetBox 2.

Configuration

Add the plugin to the NetBox config. The netbox_extensions_plugin also needs to be loaded.

PLUGINS = [
	"netbox_capirca_plugin",
	"netbox_extensions_plugin",
]

This plugin has there configuration parameters:

  • policy_base_path - The directory in which the policies are
  • definitions_path - The directory where the definitions are
  • default_policy_template - The default template for policies (relative to policy_base_path)

In the configuration this looks e.g. like this

PLUGINS_CONFIG = {
    'netbox_capirca_plugin': {
        'default_policy_template': 'main.pol.j2',
        'policy_base_path': '/opt/capirca/policies/',
        'definitions_path': '/opt/capirca/defs',
    }
}

Policy-Templates

The policy templates are Jinja2 Templates that are rendered into capirca policy files. The ACL object can be accessed as acl in the template. The important keys of the ACL object are name, description and terms. There is also the target and options variables. They specify for which capirca target and with options this ACL has to be rendered. To render a ACL for IPv4 you usually have to supply the option inet4 (except for standard/extended for cisco) or inet6 for IPv6. A simple template looks like this:

header {
	comment:: "{{ acl.description }}"
	target:: {{ target }} {{ acl.name }} {{ options }}
}
{{ acl.terms }}

Handling unique ACL names for IPv4 and IPv6 on Cisco IOS

Cisco ACL names have to be unique. This means that if there is an extended ACL called foo there can't be a IPv6 ACL called foo. A trick to get around this limitation is to give the resulting ipv6 ACL a slightly different name, e.g. ipv6-foo. This can be done in the template like this:

header {
        comment:: "{{ acl.description }}"
        {% if target %}
        target:: {{ target }} {% if "inet6" in options and target in ["cisco", "ciscoxr", "ciscoasa"]%}ipv6-{% endif %}{{ acl.name }} {{ options }}
        {% endif %}
}
{{ acl.terms }}

API

ACLs and ACLInterfaceAssignments can also be managed via the API. The API docs can be found where the regular NetBox API docs of your installation are.

Data Flow

The data flow for ACL rendering can be seen in this diagram:

ACL Rendering Dataflow

Metadata

Release files for netbox-capirca-plugin 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netbox-capirca-plugin 2.0.0
File Size Uploaded Provenance Actions
netbox_capirca_plugin-2.0.0.tar.gz 28.1 kB Without provenance Details for netbox_capirca_plugin-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netbox-capirca-plugin 2.0.0
File Interpreter ABI Platform Actions
netbox_capirca_plugin-2.0.0-py3-none-any.whl Python 3 none any Details for netbox_capirca_plugin-2.0.0-py3-none-any.whl

Total release size: 66.2 kB

Release files / netbox_capirca_plugin-2.0.0.tar.gz

Download URL netbox_capirca_plugin-2.0.0.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
198651983151919b552d067f2558a0a206924f5f06f42ca47f2592bd06415489
BLAKE2b-256 checksum
How to use checksums
527a484c903ddf118e365e3504df76e1c79bb27952f8132697109ee32cfa1a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / netbox_capirca_plugin-2.0.0-py3-none-any.whl

Download URL netbox_capirca_plugin-2.0.0-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ebcad1be4dad9200491bc6fd028b64bd347660b27489d0e117a4295a9bfe433
BLAKE2b-256 checksum
How to use checksums
e5c968bc19d58f74a47f93fd063d5182b1ee9628e6f5e0fe46bb2036c10de49d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Security for netbox-capirca-plugin 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page