5.2. Configure IP Addressing

You can use procedures in this section to manage your IP address allocation in OpenStack Networking.

5.2.1. Create Floating IP Pools

Floating IP addresses allow you to direct ingress network traffic to your OpenStack instances. You begin by defining a pool of validly routable external IP addresses, which can then be dynamically assigned to an instance. OpenStack Networking then knows to route all incoming traffic destined for that floating IP to the instance to which it has been assigned.
Note
OpenStack Networking allocates floating IP addresses to all projects (tenants) from the same IP ranges/CIDRs. Meaning that every subnet of floating IPs is consumable by any and all projects. You can manage this behavior using quotas for specific projects. For example, you can set the default to 10 for ProjectA and ProjectB, while setting ProjectC's quota to 0.
The Floating IP allocation pool is defined when you create an external subnet. If the subnet only hosts floating IP addresses, consider disabling DHCP allocation with the enable_dhcp=Falseoption:
# neutron subnet-create --name SUBNET_NAME --enable_dhcp=False --allocation_pool start=IP_ADDRESS,end=IP_ADDRESS --gateway=IP_ADDRESS NETWORK_NAME CIDR

Example 5.1. 

# neutron subnet-create --name public_subnet --enable_dhcp=False --allocation_pool start=192.168.100.20,end=192.168.100.100 --gateway=192.168.100.1 public 192.168.100.0/24

5.2.2. Assign a Specific Floating IP

You can assign a specific floating IP address to an instance using the nova command (or through the dashboard; see Section 3.1.2, “Update an Instance (Actions menu)”).
# nova add-floating-ip INSTANCE_NAME IP_ADDRESS

Example 5.2. 

In this example, a floating IP address is allocated to an instance named corp-vm-01:
# nova add-floating-ip corp-vm-01 192.168.100.20

5.2.3. Assign a Random Floating IP

Floating IP addresses can be dynamically allocated to instances. You do not select a particular IP address, but instead request that OpenStack Networking allocates one from the pool.
  1. Allocate a floating IP from the previously created pool:
    # neutron floatingip-create public
    +---------------------+--------------------------------------+
    | Field               | Value                                |
    +---------------------+--------------------------------------+
    | fixed_ip_address    |                                      |
    | floating_ip_address | 192.168.100.20                       |
    | floating_network_id | 7a03e6bc-234d-402b-9fb2-0af06c85a8a3 |
    | id                  | 9d7e2603482d                         |
    | port_id             |                                      |
    | router_id           |                                      |
    | status              | ACTIVE                               |
    | tenant_id           | 9e67d44eab334f07bf82fa1b17d824b6     |
    +---------------------+--------------------------------------+
    
  2. With the IP address allocated, you can assign it to a particular instance. Locate the ID of the port associated with your instance (this will match the fixed IP address allocated to the instance). This port ID is used in the following step to associate the instance's port ID with the floating IP address ID. You can further distinguish the correct port ID by ensuring the MAC address in the third column matches the one on the instance.
    # neutron port-list
    +--------+------+-------------+--------------------------------------------------------+
    | id     | name | mac_address | fixed_ips                                              |
    +--------+------+-------------+--------------------------------------------------------+
    | ce8320 |      | 3e:37:09:4b | {"subnet_id": "361f27", "ip_address": "192.168.100.2"} |
    | d88926 |      | 3e:1d:ea:31 | {"subnet_id": "361f27", "ip_address": "192.168.100.5"} |
    | 8190ab |      | 3e:a3:3d:2f | {"subnet_id": "b74dbb", "ip_address": "10.10.1.25"}|
    +--------+------+-------------+--------------------------------------------------------+
    
  3. Use the neutron command to associate the floating IP address with the desired port ID of an instance:
    # neutron floatingip-associate 9d7e2603482d 8190ab

5.2.4. Create Multiple Floating IP Pools

OpenStack Networking supports one floating IP pool per L3 agent. Therefore, scaling out your L3 agents allows you to create additional floating IP pools.
    Note
    Ensure that handle_internal_only_routers in /etc/neutron/neutron.conf is configured to True for only one L3 agent in your environment. This option configures the L3 agent to manage only non-external routers.