OpenStack Add Direct Attached DHCP IPs

Direct-attached IPs (also called fixed IPs) are assigned to instances via DHCP on a Neutron network. Unlike floating IPs, these addresses are allocated from the subnet range when the instance boots. This guide covers creating provider networks with DHCP in OpenStack 2024.2 Dalmatian so instances receive routable IPs directly.

Direct-Attached vs Floating IPs

Feature Direct-Attached (Fixed) IP Floating IP
Assignment Automatic via DHCP at boot Manual post-boot
Network type Provider or tenant network Mapped from external network
NAT required No (if provider network) Yes (DNAT/SNAT)
Performance Best (no NAT overhead) Slight overhead
Use case Bare-metal, HPC, direct routing General-purpose VMs

Prerequisites

Requirement Details
OpenStack 2024.2 Dalmatian
Physical network VLAN or flat network accessible by instances
Neutron ML2 plugin with flat or VLAN type driver
DHCP agent Running on at least one network node

Step 1: Configure the Physical Network Mapping

On the controller, edit /etc/neutron/plugins/ml2/ml2_conf.ini:

[ml2]
type_drivers = flat,vlan,vxlan

[ml2_type_flat]
flat_networks = physnet1

[ml2_type_vlan]
network_vlan_ranges = physnet1:100:200

On each compute and network node, edit the OVS or Linux bridge agent config:

# For OVS: openvswitch_agent.ini
[ovs]
bridge_mappings = physnet1:br-provider

# For Linux Bridge: linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = physnet1:ens224

Step 2: Create a Flat Provider Network

A flat provider network maps directly to a physical network without VLAN tagging:

openstack network create \
  --provider-network-type flat \
  --provider-physical-network physnet1 \
  --share \
  --external \
  direct-net

Create a subnet with DHCP enabled:

openstack subnet create \
  --network direct-net \
  --subnet-range 10.100.0.0/24 \
  --allocation-pool start=10.100.0.100,end=10.100.0.200 \
  --gateway 10.100.0.1 \
  --dns-nameserver 8.8.8.8 \
  --dhcp \
  direct-subnet

Step 3: Create a VLAN Provider Network

Alternatively, use a VLAN provider network for isolation:

openstack network create \
  --provider-network-type vlan \
  --provider-physical-network physnet1 \
  --provider-segment 150 \
  --share \
  vlan150-net

openstack subnet create \
  --network vlan150-net \
  --subnet-range 10.150.0.0/24 \
  --allocation-pool start=10.150.0.100,end=10.150.0.200 \
  --gateway 10.150.0.1 \
  --dns-nameserver 8.8.8.8 \
  --dhcp \
  vlan150-subnet

Step 4: Launch an Instance on the Provider Network

openstack server create \
  --flavor m1.small \
  --image "Ubuntu 22.04" \
  --network direct-net \
  direct-vm

The instance will receive an IP via DHCP from the allocation pool (e.g., 10.100.0.100).

Verify:

openstack server show direct-vm -c addresses

Step 5: Manage DHCP Allocations

List ports and their fixed IPs:

openstack port list --network direct-net

Assign a specific IP to an instance:

openstack port create \
  --network direct-net \
  --fixed-ip subnet=direct-subnet,ip-address=10.100.0.150 \
  reserved-port

openstack server create \
  --flavor m1.small \
  --image "Ubuntu 22.04" \
  --port reserved-port \
  specific-ip-vm

Step 6: Add Multiple IPs to an Instance

Create an additional port and attach it:

openstack port create --network direct-net extra-port
openstack server add port my-vm extra-port

Inside the VM, configure the new interface:

sudo dhclient ens4  # or use netplan

DHCP Agent Configuration

Key settings in /etc/neutron/dhcp_agent.ini:

[DEFAULT]
interface_driver = openvswitch  # or linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
force_metadata = true

For high availability, run multiple DHCP agents:

# /etc/neutron/neutron.conf
[DEFAULT]
dhcp_agents_per_network = 2

Troubleshooting

Issue Fix
VM gets no IP Verify DHCP agent is running and assigned to the network
Wrong subnet Check allocation pool and subnet CIDR
Duplicate IP Look for conflicting ports: openstack port list
No external connectivity Verify physical switch VLAN/trunk configuration

Summary

Direct-attached DHCP IPs on provider networks give instances routable addresses without NAT overhead. This is the preferred approach for bare-metal workloads, HPC, and any scenario where floating IP NAT is undesirable.