IPAM Examples
Examples for IP Address Management (IPAM) operations.
IP Addresses
List All IP Addresses
Get-NBIPAMAddress
Get IP by Address
Get-NBIPAMAddress -Address '10.0.0.1'
Get IPs in a Prefix
Get-NBIPAMAddress -Parent '10.0.0.0/24'
Get Active IPs
Get-NBIPAMAddress -Status 'active'
Create an IP Address
New-NBIPAMAddress -Address '10.0.0.1/24' -Description 'Web Server' -Status 'active'
Create IP with Tenant
New-NBIPAMAddress -Address '10.0.0.2/24' -Tenant 1 -Description 'Database Server'
Update an IP Address
Set-NBIPAMAddress -Id 1 -Description 'Updated description' -Status 'reserved'
Assign IP to Interface
Set-NBIPAMAddress -Id 1 `
-Assigned_Object_Type 'dcim.interface' `
-Assigned_Object_Id 5
Delete an IP Address
Remove-NBIPAMAddress -Id 1 -Confirm
Prefixes
List All Prefixes
Get-NBIPAMPrefix
Get Prefix by CIDR
Get-NBIPAMPrefix -Prefix '10.0.0.0/24'
Get Prefixes in a VRF
Get-NBIPAMPrefix -Vrf 1
Create a Prefix
New-NBIPAMPrefix -Prefix '192.168.1.0/24' -Site 1 -Status 'active' -Description 'Office LAN'
Get Available IPs in Prefix
# First get the prefix
$prefix = Get-NBIPAMPrefix -Prefix '10.0.0.0/24'
# Then query available IPs (via raw API)
$uri = "$($prefix.url)available-ips/"
# Note: Use Netbox UI or API directly for this operation
VLANs
List All VLANs
Get-NBIPAMVlan
Get VLAN by VID
Get-NBIPAMVlan -Vid 100
Get VLANs in a Site
Get-NBIPAMVlan -Site 1
Create a VLAN
New-NBIPAMVlan -Vid 100 -Name 'Management' -Site 1 -Status 'active'
Update a VLAN
Set-NBIPAMVlan -Id 1 -Description 'Management VLAN'
VRFs
List All VRFs
Get-NBIPAMVrf
Create a VRF
New-NBIPAMVrf -Name 'Customer-A' -Rd '65000:100' -Description 'Customer A routing domain'
Get Prefixes in VRF
$vrf = Get-NBIPAMVrf -Name 'Customer-A'
Get-NBIPAMPrefix -Vrf $vrf.id
Aggregates & RIRs
List RIRs
Get-NBIPAMRIR
Create an Aggregate
New-NBIPAMAggregate -Prefix '10.0.0.0/8' -Rir 1 -Description 'Private range'
IP Ranges
List IP Ranges
Get-NBIPAMRange
Create an IP Range
New-NBIPAMRange -Start_Address '10.0.0.100' -End_Address '10.0.0.200' -Description 'DHCP Pool'
Roles
List IPAM Roles
Get-NBIPAMRole
Create a Role
New-NBIPAMRole -Name 'Production' -Slug 'production'
Services
List Services
Get-NBIPAMService
Create a Service
New-NBIPAMService -Name 'HTTP' -Device 1 -Ports @(80, 443) -Protocol 'tcp'
Bulk Operations
Export All IPs to CSV
Get-NBIPAMAddress |
Select-Object address, status, description, @{N='tenant';E={$_.tenant.name}} |
Export-Csv -Path 'ip-addresses.csv' -NoTypeInformation
Import IPs from CSV
# ips.csv: Address,Description,Status
Import-Csv ips.csv | ForEach-Object {
New-NBIPAMAddress -Address $_.Address -Description $_.Description -Status $_.Status
}
Find Duplicate IPs
Get-NBIPAMAddress |
Group-Object address |
Where-Object { $_.Count -gt 1 } |
Select-Object Name, Count
Find Unassigned IPs
Get-NBIPAMAddress | Where-Object { -not $_.assigned_object }
Count IPs per Status
Get-NBIPAMAddress |
Group-Object status |
Select-Object @{N='Status';E={$_.Name}}, Count |
Sort-Object Count -Descending
VLAN Usage Report
Get-NBIPAMVlan |
Select-Object vid, name, @{N='site';E={$_.site.name}}, status |
Sort-Object vid |
Format-Table -AutoSize