or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

circuits.mdcloud.mdcore-framework.mddcim.mdextensibility.mdindex.mdipam.mdtenancy-users.mdvirtualization-cloud.mdwireless.md

ipam.mddocs/

0

# IP Address Management (IPAM)

1

2

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.

3

4

## Capabilities

5

6

### Namespace Management

7

8

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

9

10

```python { .api }

11

class Namespace:

12

"""

13

IP namespace segregation for overlapping address spaces.

14

15

Attributes:

16

name (str): Namespace name

17

description (str): Namespace description

18

location (Location): Associated location

19

"""

20

```

21

22

### VRF Management

23

24

Virtual routing and forwarding instance management.

25

26

```python { .api }

27

class VRF:

28

"""

29

Virtual routing and forwarding instances.

30

31

Attributes:

32

name (str): VRF name

33

namespace (Namespace): IP namespace

34

rd (str): Route distinguisher

35

tenant (Tenant): Tenant assignment

36

description (str): VRF description

37

import_targets (list): BGP import route targets

38

export_targets (list): BGP export route targets

39

"""

40

41

class VRFDeviceAssignment:

42

"""

43

VRF assignments to devices.

44

45

Attributes:

46

vrf (VRF): VRF instance

47

device (Device): Assigned device

48

rd (str): Device-specific route distinguisher

49

"""

50

51

class VRFPrefixAssignment:

52

"""

53

VRF assignments to prefixes.

54

55

Attributes:

56

vrf (VRF): VRF instance

57

prefix (Prefix): Assigned prefix

58

"""

59

```

60

61

### IP Address and Prefix Management

62

63

Core IP address space management with hierarchical prefixes.

64

65

```python { .api }

66

class Prefix:

67

"""

68

IP prefixes/networks with hierarchical organization.

69

70

Attributes:

71

prefix (str): Network prefix (e.g., "192.168.1.0/24")

72

namespace (Namespace): IP namespace

73

type (str): Prefix type (network, pool, container)

74

status (Status): Prefix status

75

tenant (Tenant): Tenant assignment

76

vrf (VRF): VRF assignment

77

location (Location): Associated location

78

date_allocated (date): Allocation date

79

description (str): Prefix description

80

is_pool (bool): Whether prefix is an IP pool

81

mark_utilized (bool): Whether to mark as utilized

82

parent (Prefix): Parent prefix in hierarchy

83

"""

84

85

class IPAddress:

86

"""

87

Individual IP addresses with assignments.

88

89

Attributes:

90

address (str): IP address with mask (e.g., "192.168.1.1/24")

91

namespace (Namespace): IP namespace

92

parent (Prefix): Parent prefix

93

status (Status): Address status

94

role (str): Address role (loopback, secondary, anycast, etc.)

95

tenant (Tenant): Tenant assignment

96

assigned_object_type (ContentType): Type of assigned object

97

assigned_object_id (UUID): ID of assigned object

98

assigned_object (object): Assigned object (Interface, VMInterface, etc.)

99

nat_inside (IPAddress): NAT inside address

100

nat_outside (list): NAT outside addresses

101

dns_name (str): DNS name

102

description (str): Address description

103

"""

104

105

class IPAddressToInterface:

106

"""

107

IP address to interface mapping relationships.

108

109

Attributes:

110

ip_address (IPAddress): IP address

111

interface (Interface): Network interface

112

vm_interface (VMInterface): Virtual machine interface

113

"""

114

115

class PrefixLocationAssignment:

116

"""

117

Prefix assignments to locations.

118

119

Attributes:

120

prefix (Prefix): IP prefix

121

location (Location): Assigned location

122

"""

123

```

124

125

### VLAN Management

126

127

Virtual LAN management with hierarchical grouping.

128

129

```python { .api }

130

class VLANGroup:

131

"""

132

VLAN grouping for organization.

133

134

Attributes:

135

name (str): Group name

136

description (str): Group description

137

location (Location): Associated location

138

"""

139

140

class VLAN:

141

"""

142

Virtual LANs with VLAN ID management.

143

144

Attributes:

145

vid (int): VLAN ID (1-4094)

146

name (str): VLAN name

147

vlan_group (VLANGroup): VLAN group assignment

148

tenant (Tenant): Tenant assignment

149

status (Status): VLAN status

150

role (Role): VLAN role

151

description (str): VLAN description

152

location (Location): Associated location

153

"""

154

155

class VLANLocationAssignment:

156

"""

157

VLAN assignments to locations.

158

159

Attributes:

160

vlan (VLAN): VLAN

161

location (Location): Assigned location

162

"""

163

```

164

165

### BGP and MPLS Support

166

167

BGP route targets for MPLS VPN implementations.

168

169

```python { .api }

170

class RouteTarget:

171

"""

172

BGP route targets for MPLS VPN.

173

174

Attributes:

175

name (str): Route target name (e.g., "65000:100")

176

tenant (Tenant): Tenant assignment

177

description (str): Route target description

178

importing_vrfs (list): VRFs importing this target

179

exporting_vrfs (list): VRFs exporting this target

180

"""

181

```

182

183

### Regional Internet Registries

184

185

RIR management for IP address allocation tracking.

186

187

```python { .api }

188

class RIR:

189

"""

190

Regional Internet Registries for IP allocation tracking.

191

192

Attributes:

193

name (str): RIR name (ARIN, RIPE, APNIC, etc.)

194

slug (str): URL-safe slug

195

is_private (bool): Whether RIR handles private space

196

description (str): RIR description

197

"""

198

```

199

200

### Network Services

201

202

Service definitions for network service management.

203

204

```python { .api }

205

class Service:

206

"""

207

Network services running on devices or virtual machines.

208

209

Attributes:

210

device (Device): Host device

211

virtual_machine (VirtualMachine): Host virtual machine

212

name (str): Service name

213

protocol (str): Service protocol (TCP/UDP)

214

ports (list): Service port numbers

215

description (str): Service description

216

ipaddresses (list): Service IP addresses

217

"""

218

```

219

220

## Usage Examples

221

222

### IP Address Management

223

224

```python

225

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

226

from nautobot.extras.models import Status

227

228

# Create namespace

229

namespace = Namespace.objects.create(

230

name="Corporate",

231

description="Corporate network namespace"

232

)

233

234

# Create prefix

235

active_status = Status.objects.get(name="Active")

236

prefix = Prefix.objects.create(

237

prefix="192.168.0.0/16",

238

namespace=namespace,

239

status=active_status,

240

description="Corporate network"

241

)

242

243

# Create IP address

244

ip = IPAddress.objects.create(

245

address="192.168.1.1/24",

246

namespace=namespace,

247

parent=prefix,

248

status=active_status,

249

description="Gateway address"

250

)

251

252

# Assign IP to interface

253

from nautobot.dcim.models import Interface

254

interface = Interface.objects.get(device__name="router-01", name="Gi0/0/0")

255

ip.assigned_object = interface

256

ip.save()

257

258

# Get all IPs in a prefix

259

prefix_ips = IPAddress.objects.filter(parent=prefix)

260

```

261

262

### Prefix Hierarchy

263

264

```python

265

from nautobot.ipam.models import Prefix

266

267

# Create parent prefix

268

parent_prefix = Prefix.objects.create(

269

prefix="10.0.0.0/8",

270

namespace=namespace,

271

status=active_status,

272

type="container",

273

description="Private network space"

274

)

275

276

# Create child prefixes

277

subnet1 = Prefix.objects.create(

278

prefix="10.1.0.0/16",

279

namespace=namespace,

280

parent=parent_prefix,

281

status=active_status,

282

description="Site 1 network"

283

)

284

285

subnet2 = Prefix.objects.create(

286

prefix="10.2.0.0/16",

287

namespace=namespace,

288

parent=parent_prefix,

289

status=active_status,

290

description="Site 2 network"

291

)

292

293

# Get all child prefixes

294

child_prefixes = Prefix.objects.filter(parent=parent_prefix)

295

```

296

297

### VLAN Management

298

299

```python

300

from nautobot.ipam.models import VLAN, VLANGroup

301

from nautobot.dcim.models import Location

302

303

# Create VLAN group

304

location = Location.objects.get(name="DataCenter-1")

305

vlan_group = VLANGroup.objects.create(

306

name="DC1-VLANs",

307

location=location,

308

description="DataCenter 1 VLANs"

309

)

310

311

# Create VLANs

312

vlan_100 = VLAN.objects.create(

313

vid=100,

314

name="Users",

315

vlan_group=vlan_group,

316

status=active_status,

317

description="User network VLAN"

318

)

319

320

vlan_200 = VLAN.objects.create(

321

vid=200,

322

name="Servers",

323

vlan_group=vlan_group,

324

status=active_status,

325

description="Server network VLAN"

326

)

327

328

# Get VLANs by group

329

group_vlans = VLAN.objects.filter(vlan_group=vlan_group)

330

```

331

332

### VRF Management

333

334

```python

335

from nautobot.ipam.models import VRF, RouteTarget

336

337

# Create route targets

338

import_rt = RouteTarget.objects.create(

339

name="65000:100",

340

description="Import route target"

341

)

342

343

export_rt = RouteTarget.objects.create(

344

name="65000:101",

345

description="Export route target"

346

)

347

348

# Create VRF

349

vrf = VRF.objects.create(

350

name="CUSTOMER-A",

351

namespace=namespace,

352

rd="65000:100",

353

description="Customer A VRF"

354

)

355

356

# Assign route targets

357

vrf.import_targets.add(import_rt)

358

vrf.export_targets.add(export_rt)

359

360

# Assign VRF to device

361

from nautobot.ipam.models import VRFDeviceAssignment

362

from nautobot.dcim.models import Device

363

364

device = Device.objects.get(name="router-01")

365

VRFDeviceAssignment.objects.create(

366

vrf=vrf,

367

device=device

368

)

369

```

370

371

### Service Management

372

373

```python

374

from nautobot.ipam.models import Service

375

376

# Create service on device

377

service = Service.objects.create(

378

device=device,

379

name="SSH",

380

protocol="tcp",

381

ports=[22],

382

description="SSH management service"

383

)

384

385

# Assign IP addresses to service

386

service.ipaddresses.add(ip)

387

388

# Get all services on device

389

device_services = Service.objects.filter(device=device)

390

```

391

392

### IP Address Queries

393

394

```python

395

# Find available IPs in prefix

396

available_ips = prefix.get_available_ips()

397

398

# Get first available IP

399

first_available = available_ips.first() if available_ips else None

400

401

# Check IP utilization

402

utilization = prefix.get_utilization()

403

print(f"Prefix utilization: {utilization}%")

404

405

# Find overlapping prefixes

406

overlapping = Prefix.objects.filter(

407

prefix__net_overlaps=prefix.prefix

408

).exclude(pk=prefix.pk)

409

```

410

411

### Advanced Filtering

412

413

```python

414

# Get all IP addresses by status

415

reserved_ips = IPAddress.objects.filter(status__name="Reserved")

416

active_ips = IPAddress.objects.filter(status__name="Active")

417

418

# Get IPs assigned to interfaces

419

interface_ips = IPAddress.objects.filter(

420

assigned_object_type__model='interface'

421

)

422

423

# Get prefixes by location

424

location_prefixes = Prefix.objects.filter(location=location)

425

426

# Get VLANs by VLAN ID range

427

vlans_100_199 = VLAN.objects.filter(vid__range=(100, 199))

428

```

429

430

### Namespace Isolation

431

432

```python

433

# Create multiple namespaces for isolation

434

prod_namespace = Namespace.objects.create(

435

name="Production",

436

description="Production environment"

437

)

438

439

dev_namespace = Namespace.objects.create(

440

name="Development",

441

description="Development environment"

442

)

443

444

# Same IP space in different namespaces

445

prod_ip = IPAddress.objects.create(

446

address="192.168.1.1/24",

447

namespace=prod_namespace,

448

status=active_status

449

)

450

451

dev_ip = IPAddress.objects.create(

452

address="192.168.1.1/24", # Same IP, different namespace

453

namespace=dev_namespace,

454

status=active_status

455

)

456

457

# Query by namespace

458

prod_ips = IPAddress.objects.filter(namespace=prod_namespace)

459

dev_ips = IPAddress.objects.filter(namespace=dev_namespace)

460

```