Skip to main content

Allocate IP addresses

IP address pools (CoreIPAddressPool) dynamically allocate individual IP addresses from source prefixes.

Prerequisites​

  • A running Infrahub instance
Schema used in this guide

The examples on this page use the following schema nodes. Adapt the type names to match your own schema.

nodes:
- name: IPPrefix
namespace: Ipam
inherit_from:
- "BuiltinIPPrefix"

- name: IPAddress
namespace: Ipam
inherit_from:
- "BuiltinIPAddress"

- name: Device
namespace: Infra
human_friendly_id: ["name__value"]
attributes:
- name: name
kind: Text
unique: true
relationships:
- name: primary_ip
peer: IpamIPAddress
kind: Attribute
cardinality: one

Step 1: Create an IP prefix object​

Create the IP prefix that serves as the allocation source:

Navigate to IPAM → IP Prefixes and create a new prefix with:

  • Prefix: 10.100.0.0/24
  • Member Type: address

Creating prefix 10.100.0 via the Web Interface

Step 2: Create the IP address pool​

Create a CoreIPAddressPool Resource Manager:

Navigate to Object Management → Resource Manager and create a new IP Address Pool with:

  • Name: My IP address pool
  • Default Address Type: IpamIPAddress
  • Default Prefix Length: 24
  • Resources: Select the 10.100.0.0/24 prefix
  • IP Namespace: default

Creating IP address pool via the Web Interface

Step 3: Allocate IP addresses​

You can allocate IP addresses in two ways: direct allocation or allocation during node creation.

Direct allocation​

Allocate an IP address directly from the pool:

Create an IP address. Next to the Address field, click the pool button, labeled "select a pool", and choose My IP address pool, then save. Infrahub allocates the next available address from the pool and creates the IP address with it.

Infrahub allocates a new address on each save. To get the same address back when a script or a Generator runs again, use the GraphQL method with an identifier.

success

You have created an IP address record from the pool!

Allocation during node creation​

Allocate an IP address when creating a device:

Navigate to Devices → Add Device. Next to the Primary IP Address field, click the pool button, labeled "select a pool", and choose your resource pool.

Device creation via the Web Interface - Before Device creation via the Web Interface - After

success

The device is created with primary IP address allocated from the pool!

Next​