CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-nautobot

Source of truth and network automation platform for network infrastructure management.

Pending
Overview
Eval results
Files

ipam.mddocs/

IP Address Management (IPAM)

IP address space management including prefixes, IP addresses, VLANs, VRFs, namespaces, and routing. Supports hierarchical IP space organization and VLAN management with multi-tenancy and namespace isolation.

Capabilities

Namespace Management

IP namespace segregation for multi-tenancy and address space organization.

class Namespace:
    """
    IP namespace segregation for overlapping address spaces.
    
    Attributes:
        name (str): Namespace name
        description (str): Namespace description
        location (Location): Associated location
    """

VRF Management

Virtual routing and forwarding instance management.

class VRF:
    """
    Virtual routing and forwarding instances.
    
    Attributes:
        name (str): VRF name
        namespace (Namespace): IP namespace
        rd (str): Route distinguisher
        tenant (Tenant): Tenant assignment
        description (str): VRF description
        import_targets (list): BGP import route targets
        export_targets (list): BGP export route targets
    """

class VRFDeviceAssignment:
    """
    VRF assignments to devices.
    
    Attributes:
        vrf (VRF): VRF instance
        device (Device): Assigned device
        rd (str): Device-specific route distinguisher
    """

class VRFPrefixAssignment:
    """
    VRF assignments to prefixes.
    
    Attributes:
        vrf (VRF): VRF instance
        prefix (Prefix): Assigned prefix
    """

IP Address and Prefix Management

Core IP address space management with hierarchical prefixes.

class Prefix:
    """
    IP prefixes/networks with hierarchical organization.
    
    Attributes:
        prefix (str): Network prefix (e.g., "192.168.1.0/24")
        namespace (Namespace): IP namespace
        type (str): Prefix type (network, pool, container)
        status (Status): Prefix status
        tenant (Tenant): Tenant assignment
        vrf (VRF): VRF assignment
        location (Location): Associated location
        date_allocated (date): Allocation date
        description (str): Prefix description
        is_pool (bool): Whether prefix is an IP pool
        mark_utilized (bool): Whether to mark as utilized
        parent (Prefix): Parent prefix in hierarchy
    """

class IPAddress:
    """
    Individual IP addresses with assignments.
    
    Attributes:
        address (str): IP address with mask (e.g., "192.168.1.1/24")
        namespace (Namespace): IP namespace
        parent (Prefix): Parent prefix
        status (Status): Address status
        role (str): Address role (loopback, secondary, anycast, etc.)
        tenant (Tenant): Tenant assignment
        assigned_object_type (ContentType): Type of assigned object
        assigned_object_id (UUID): ID of assigned object
        assigned_object (object): Assigned object (Interface, VMInterface, etc.)
        nat_inside (IPAddress): NAT inside address
        nat_outside (list): NAT outside addresses
        dns_name (str): DNS name
        description (str): Address description
    """

class IPAddressToInterface:
    """
    IP address to interface mapping relationships.
    
    Attributes:
        ip_address (IPAddress): IP address
        interface (Interface): Network interface
        vm_interface (VMInterface): Virtual machine interface
    """

class PrefixLocationAssignment:
    """
    Prefix assignments to locations.
    
    Attributes:
        prefix (Prefix): IP prefix
        location (Location): Assigned location
    """

VLAN Management

Virtual LAN management with hierarchical grouping.

class VLANGroup:
    """
    VLAN grouping for organization.
    
    Attributes:
        name (str): Group name
        description (str): Group description
        location (Location): Associated location
    """

class VLAN:
    """
    Virtual LANs with VLAN ID management.
    
    Attributes:
        vid (int): VLAN ID (1-4094)
        name (str): VLAN name
        vlan_group (VLANGroup): VLAN group assignment
        tenant (Tenant): Tenant assignment
        status (Status): VLAN status
        role (Role): VLAN role
        description (str): VLAN description
        location (Location): Associated location
    """

class VLANLocationAssignment:
    """
    VLAN assignments to locations.
    
    Attributes:
        vlan (VLAN): VLAN
        location (Location): Assigned location
    """

BGP and MPLS Support

BGP route targets for MPLS VPN implementations.

class RouteTarget:
    """
    BGP route targets for MPLS VPN.
    
    Attributes:
        name (str): Route target name (e.g., "65000:100")
        tenant (Tenant): Tenant assignment
        description (str): Route target description
        importing_vrfs (list): VRFs importing this target
        exporting_vrfs (list): VRFs exporting this target
    """

Regional Internet Registries

RIR management for IP address allocation tracking.

class RIR:
    """
    Regional Internet Registries for IP allocation tracking.
    
    Attributes:
        name (str): RIR name (ARIN, RIPE, APNIC, etc.)
        slug (str): URL-safe slug
        is_private (bool): Whether RIR handles private space
        description (str): RIR description
    """

Network Services

Service definitions for network service management.

class Service:
    """
    Network services running on devices or virtual machines.
    
    Attributes:
        device (Device): Host device
        virtual_machine (VirtualMachine): Host virtual machine
        name (str): Service name
        protocol (str): Service protocol (TCP/UDP)
        ports (list): Service port numbers
        description (str): Service description
        ipaddresses (list): Service IP addresses
    """

Usage Examples

IP Address Management

from nautobot.ipam.models import IPAddress, Prefix, Namespace
from nautobot.extras.models import Status

# Create namespace
namespace = Namespace.objects.create(
    name="Corporate",
    description="Corporate network namespace"
)

# Create prefix
active_status = Status.objects.get(name="Active")
prefix = Prefix.objects.create(
    prefix="192.168.0.0/16",
    namespace=namespace,
    status=active_status,
    description="Corporate network"
)

# Create IP address
ip = IPAddress.objects.create(
    address="192.168.1.1/24",
    namespace=namespace,
    parent=prefix,
    status=active_status,
    description="Gateway address"
)

# Assign IP to interface
from nautobot.dcim.models import Interface
interface = Interface.objects.get(device__name="router-01", name="Gi0/0/0")
ip.assigned_object = interface
ip.save()

# Get all IPs in a prefix
prefix_ips = IPAddress.objects.filter(parent=prefix)

Prefix Hierarchy

from nautobot.ipam.models import Prefix

# Create parent prefix
parent_prefix = Prefix.objects.create(
    prefix="10.0.0.0/8",
    namespace=namespace,
    status=active_status,
    type="container",
    description="Private network space"
)

# Create child prefixes
subnet1 = Prefix.objects.create(
    prefix="10.1.0.0/16",
    namespace=namespace,
    parent=parent_prefix,
    status=active_status,
    description="Site 1 network"
)

subnet2 = Prefix.objects.create(
    prefix="10.2.0.0/16",
    namespace=namespace,
    parent=parent_prefix,
    status=active_status,
    description="Site 2 network"
)

# Get all child prefixes
child_prefixes = Prefix.objects.filter(parent=parent_prefix)

VLAN Management

from nautobot.ipam.models import VLAN, VLANGroup
from nautobot.dcim.models import Location

# Create VLAN group
location = Location.objects.get(name="DataCenter-1")
vlan_group = VLANGroup.objects.create(
    name="DC1-VLANs",
    location=location,
    description="DataCenter 1 VLANs"
)

# Create VLANs
vlan_100 = VLAN.objects.create(
    vid=100,
    name="Users",
    vlan_group=vlan_group,
    status=active_status,
    description="User network VLAN"
)

vlan_200 = VLAN.objects.create(
    vid=200,
    name="Servers",
    vlan_group=vlan_group,
    status=active_status,
    description="Server network VLAN"
)

# Get VLANs by group
group_vlans = VLAN.objects.filter(vlan_group=vlan_group)

VRF Management

from nautobot.ipam.models import VRF, RouteTarget

# Create route targets
import_rt = RouteTarget.objects.create(
    name="65000:100",
    description="Import route target"
)

export_rt = RouteTarget.objects.create(
    name="65000:101",
    description="Export route target"
)

# Create VRF
vrf = VRF.objects.create(
    name="CUSTOMER-A",
    namespace=namespace,
    rd="65000:100",
    description="Customer A VRF"
)

# Assign route targets
vrf.import_targets.add(import_rt)
vrf.export_targets.add(export_rt)

# Assign VRF to device
from nautobot.ipam.models import VRFDeviceAssignment
from nautobot.dcim.models import Device

device = Device.objects.get(name="router-01")
VRFDeviceAssignment.objects.create(
    vrf=vrf,
    device=device
)

Service Management

from nautobot.ipam.models import Service

# Create service on device
service = Service.objects.create(
    device=device,
    name="SSH",
    protocol="tcp",
    ports=[22],
    description="SSH management service"
)

# Assign IP addresses to service
service.ipaddresses.add(ip)

# Get all services on device
device_services = Service.objects.filter(device=device)

IP Address Queries

# Find available IPs in prefix
available_ips = prefix.get_available_ips()

# Get first available IP
first_available = available_ips.first() if available_ips else None

# Check IP utilization
utilization = prefix.get_utilization()
print(f"Prefix utilization: {utilization}%")

# Find overlapping prefixes
overlapping = Prefix.objects.filter(
    prefix__net_overlaps=prefix.prefix
).exclude(pk=prefix.pk)

Advanced Filtering

# Get all IP addresses by status
reserved_ips = IPAddress.objects.filter(status__name="Reserved")
active_ips = IPAddress.objects.filter(status__name="Active")

# Get IPs assigned to interfaces
interface_ips = IPAddress.objects.filter(
    assigned_object_type__model='interface'
)

# Get prefixes by location
location_prefixes = Prefix.objects.filter(location=location)

# Get VLANs by VLAN ID range
vlans_100_199 = VLAN.objects.filter(vid__range=(100, 199))

Namespace Isolation

# Create multiple namespaces for isolation
prod_namespace = Namespace.objects.create(
    name="Production",
    description="Production environment"
)

dev_namespace = Namespace.objects.create(
    name="Development", 
    description="Development environment"
)

# Same IP space in different namespaces
prod_ip = IPAddress.objects.create(
    address="192.168.1.1/24",
    namespace=prod_namespace,
    status=active_status
)

dev_ip = IPAddress.objects.create(
    address="192.168.1.1/24",  # Same IP, different namespace
    namespace=dev_namespace,
    status=active_status
)

# Query by namespace
prod_ips = IPAddress.objects.filter(namespace=prod_namespace)
dev_ips = IPAddress.objects.filter(namespace=dev_namespace)

Install with Tessl CLI

npx tessl i tessl/pypi-nautobot@2.4.1

docs

circuits.md

cloud.md

core-framework.md

dcim.md

extensibility.md

index.md

ipam.md

tenancy-users.md

virtualization-cloud.md

wireless.md

tile.json