Skip to main content

Allocate IP prefixes

IP prefix pools (CoreIPPrefixPool) allocate IP subnets from larger 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.

generics:
- name: Service
namespace: Infra
human_friendly_id: ["name__value"]
attributes:
- name: name
kind: Text

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

- name: Service
namespace: Customer
inherit_from:
- InfraService
relationships:
- name: assigned_prefix
peer: IpamIPPrefix
kind: Attribute
cardinality: one

Step 1: Create a source prefix​

Create the parent prefix:

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

  • Prefix: 10.100.1.0/24
  • Member Type: prefix

Creating prefix 10.100.1.0 via the Web Interface

Step 2: Create the IP prefix pool​

Create a CoreIPPrefixPool Resource Manager:

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

  • Name: Customer Service Pool
  • Default Prefix Type: IpamIPPrefix
  • Default Prefix Length: 31
  • Resources: Select the 10.100.1.0/24 prefix
  • IP Namespace: default

Creating Prefix Pool via the Web Interface

Step 3: Allocate IP prefixes​

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

Direct allocation​

Allocate an IP prefix directly from the pool:

Create an IP prefix. Next to the Prefix field, click the pool button, labeled "select a pool", and choose Customer Service Pool, then save. Infrahub allocates the next available subnet from the pool and creates the IP prefix with it.

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

success

You have created an IP prefix record from the pool!

Allocation during node creation​

Allocate an IP prefix when creating a customer service:

Navigate to Customer Service → Add Customer Service.

Next to the Assigned Prefix field, click the pool button, labeled "select a pool", and choose your resource pool.

success

The customer service is created with an IP prefix allocated from the pool!

Next​