All Projects → oz123 → coredns-netbox-plugin

oz123 / coredns-netbox-plugin

Licence: Apache-2.0 license
A coredns plugin to get dns records from Netbox

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to coredns-netbox-plugin

coredns-dockerdiscovery
Docker Discovery Plugin for CoreDNS
Stars: ✭ 36 (+2.86%)
Mutual labels:  coredns, coredns-plugin
dnsredir
Yet another seems better forward/proxy plugin for CoreDNS
Stars: ✭ 58 (+65.71%)
Mutual labels:  coredns, coredns-plugin
hphr
Halophile Router (a VyOS-based, SaltStack-automated, NetBox-configured router for small provider networks)
Stars: ✭ 39 (+11.43%)
Mutual labels:  netbox
dnstap-receiver
Dnstap streams receiver in Python
Stars: ✭ 33 (-5.71%)
Mutual labels:  coredns
Netbox
Infrastructure resource modeling for network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
Stars: ✭ 9,310 (+26500%)
Mutual labels:  netbox
network-importer
The network importer is a tool/library to analyze and/or synchronize an existing network with a Network Source of Truth (SOT), it's designed to be idempotent and by default it's only showing the difference between the running network and the remote SOT.
Stars: ✭ 120 (+242.86%)
Mutual labels:  netbox
netbox automation
Manage netbox configuration with automation. Netbox as a the source of truth: generate an ansible inventory file from Netbox with automation, generate yaml files for ansible playbooks or jinja templates from Netbox with automation
Stars: ✭ 28 (-20%)
Mutual labels:  netbox
coredns
CoreDNS is a DNS server that chains plugins
Stars: ✭ 8,962 (+25505.71%)
Mutual labels:  coredns
yaani
Yet another Ansible Netbox inventory
Stars: ✭ 12 (-65.71%)
Mutual labels:  netbox
netbox-agent
Netbox agent to run on your infrastructure's servers
Stars: ✭ 99 (+182.86%)
Mutual labels:  netbox
django-netbox-graphql
Django module which provides a GraphQL API for Netbox
Stars: ✭ 16 (-54.29%)
Mutual labels:  netbox
ttl255.com
ttl255.com - Resources
Stars: ✭ 31 (-11.43%)
Mutual labels:  netbox
netbox-paloalto
NetBox plugin for listing firewall rules (from a Palo Alto Networks firewall/Panorama) associated with a NetBox object.
Stars: ✭ 27 (-22.86%)
Mutual labels:  netbox
netbox-sync
Sync objects from VMware or redfish sources to NetBox
Stars: ✭ 172 (+391.43%)
Mutual labels:  netbox
ntmap
Network topology map using Netbox as a data source
Stars: ✭ 74 (+111.43%)
Mutual labels:  netbox
netbox-bgp
NetBox plugin for BGP related objects documentation
Stars: ✭ 135 (+285.71%)
Mutual labels:  netbox
Follow Me Install Kubernetes Cluster
和我一步步部署 kubernetes 集群
Stars: ✭ 6,662 (+18934.29%)
Mutual labels:  coredns
netbox-plugin-skeleton
Skeleton for starting NetBox plugins
Stars: ✭ 15 (-57.14%)
Mutual labels:  netbox
netbox-chart
A Helm chart for NetBox
Stars: ✭ 141 (+302.86%)
Mutual labels:  netbox
netbox-joined-inventory
Netbox_joined_inventory is a python script that gathers data from a Netbox source-of-truth and stores them as Ansible inventory, group_vars and host_vars files.
Stars: ✭ 21 (-40%)
Mutual labels:  netbox

coredns-netbox-plugin

This plugin gets an A record from NetBox1. It uses the REST API of netbox to ask for a an IP address of a hostname:

curl https://netbox.example.org/api/ipam/ip-addresses/?dns_name=example-vm-host

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "family": {
                "value": 4,
                "label": "IPv4"
            },
            "address": "192.168.1.101/25",
            "interface": {
                "id": 452,
                "url": "https://netbox.example.org/api/virtualization/interfaces/452/",
                "virtual_machine": {
                    "url": "https://netbox.example.org/api/virtualization/virtual-machines/10/",
                },
            },
        }
    ]
}

Enabling

To activate the netbox plugin you need to compile CoreDNS with the plugin added to plugin.cfg

netbox:github.com/oz123/coredns-netbox-plugin

Ordering in plugin.cfg

The ordering of plugins in the plugin.cfg file is important to ensure you get the behaviour you expect when using multiple plugins in a Corefile server block.

For example, in order to utilise the native cache plugin, ensure that you add the netbox plugin after cache:cache but before any plugins you want to be able to fall-through to (eg file:file or forward:forward).

Syntax

netbox [ZONES...] {
  token TOKEN
  url URL
  tls CERT KEY CACERT
  fallthrough [ZONES...]
}
  • ZONES zones that the netbox should be authoritative for.

  • token TOKEN sets the API token used to authenticate against NetBox (REQUIRED).

  • url URL defines the URL netbox should query. This URL must be specified in full as SCHEME://HOST/api/ipam/ip-addresses (REQUIRED).

  • tls is followed by:

    • no arguments, if the server certificate is signed by a system-installed CA and no client cert is needed (this is the default if HTTPS is used).
    • a single argument that is the CA PEM file, if the server cert is not signed by a system CA and no client cert is needed.
    • two arguments - path to cert PEM file, the path to private key PEM file - if the server certificate is signed by a system-installed CA and a client certificate is needed.
    • three arguments - path to cert PEM file, path to client private key PEM file, path to CA PEM file - if the server certificate is not signed by a system-installed CA and client certificate is needed.

    These options set certificate verification method for the NetBox server if HTTPS is used to access the API.

  • ttl DURATION defines the TTL of records returned from netbox. Default is 1h (3600s).

  • timeout DURATION defines the HTTP timeout for API requests against NetBox. Default is 5s.

  • fallthrough If a zone matches but no record can be generated, pass request to the next plugin. If [ZONES…] is omitted, then fallthrough happens for all zones for which the plugin is authoritative. If specific zones are listed then only queries for those zones will be subject to fallthrough.

The config parameters token, url and localCacheDuration are required.

Examples

Send all requests to NetBox:

. {
    netbox {
        token SuperSecretNetBoxAPIToken
        url https://netbox.example.org/api/ipam/ip-addresses
    }
}

Send requests within example.org to NetBox and fall-through to the file plugin in order to respond to unsupported record types (ie SOA, NS etc):

. {
    netbox example.org {
        token SuperSecretNetBoxAPIToken
        url https://netbox.example.org/api/ipam/ip-addresses
        fallthrough
    }
    file db.example.org
}

Handle all requests with netbox and fall-through to the forward plugin for requests within example.org with caching via the cache plugin:

. {
    netbox {
        token SuperSecretNetBoxAPIToken
        url https://netbox.example.org/api/ipam/ip-addresses
        fallthrough example.org
    }
    forward . 1.1.1.1 1.0.0.1
    cache
}

Changelog

0.2 - Cleanup add IPv6 support

  • Refactor query.go
  • Add tests for IPv6
  • Enable IPv6 in query.go

0.1 - Initial Naive release

  • Got it somehow working
  • Gather feedback

Developing locally

You can test the plugin functionallity with CoreDNS by adding the following to go.mod in the source code directory of coredns.

replace github.com/oz123/coredns-netbox-plugin => <path-to-you-local-copy>/coredns-netbox-plugin

Testing against a remote instance of netbox is possible with SSH port forwarding:

Host YourHost
   Hostname 10.0.0.91
   ProxyJump YourJumpHost
   LocalForward 18443 192.168.1.128:8443

Credits

This plugin is heavily based on the code of the redis-plugin for CoreDNS.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].