An allocation pool is a range of IP addresses that are automatically assigned to devices in a Metacloud subnet. You can reset the range by changing the "start" or "end" addresses, which is useful in certain situations, such as resolving an IP address conflict. For example, a pool may include the address 192.168.2.4, which is also assigned to a switch.
After resetting the address range in the allocation pool, you must reset the DHCP agent, as shown in the following steps.
Resetting the Address Range in the Allocation Pool
1. Obtain the ID of the subnet:
$ openstack subnet list +--------------------------------------+-------------------------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+-------------------------------+--------------------------------------+------------------+ | <subnet_UUID> | PUBLIC SUBNET - DO NOT MODIFY | <network_UUID> | 184.94.253.64/26 | | <subnet_UUID> | subnet2 | <network_UUID> | 192.168.2.0/24 | | <subnet_UUID> | oob-subnet | <network_UUID> | 10.200.200.0/24 | +--------------------------------------+-------------------------------+--------------------------------------+------------------+
2. View the allocation pool range for the subnet:
$ openstack subnet show <subnet_UUID> +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | allocation_pools | 192.168.2.4-192.168.2.254 | | cidr | 192.168.2.0/24 | | created_at | None | | description | None | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 192.168.2.1 | | host_routes | | | id | <subnet_UUID> | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet2 | | network_id | <network_UUID> | | project_id | <project_UUID> | | revision_number | None | | segment_id | None | | service_types | None | | subnetpool_id | None | | tags | None | | updated_at | None | | use_default_subnet_pool | None | +-------------------------+--------------------------------------+
3. Remove the allocation pool:
$ openstack subnet unset --allocation-pool start=192.168.2.4,end=192.168.2.254 <subnet_ID>
The unset
and set
commands typically do not generate output, but in some versions of OpenStack, you may see the following message, which you can disregard:
'NoneType' object is not iterable
4. Verify the removal of the allocation pool:
$ openstack subnet show <subnet_UUID> +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | allocation_pools | | | cidr | 192.168.2.0/24 | | created_at | None | | description | None | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 192.168.2.1 | | host_routes | | | id | <subnet_UUID> | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet2 | | network_id | <network_UUID> | | project_id | <project_UUID> | | revision_number | None | | segment_id | None | | service_types | None | | subnetpool_id | None | | tags | None | | updated_at | None | | use_default_subnet_pool | None | +-------------------------+--------------------------------------+
5. Reset the allocation pool range to start with an address that contains a higher final digit than that of the address that is causing the conflict. For example, the disputed address ends with .4, so set the "start" value at .5:
$ openstack subnet set --allocation-pool start=192.168.2.5,end=192.168.2.254 <subnet_UUID>
6. Verify that the allocation pool has been reset:
$ openstack subnet show <subnet_UUID> +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | allocation_pools | 192.168.2.5-192.168.2.254 | | cidr | 192.168.2.0/24 | | created_at | None | | description | None | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 192.168.2.1 | | host_routes | | | id | <subnet_UUID> | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet2 | | network_id | <network_UUID> | | project_id | <project_UUID> | | revision_number | None | | segment_id | None | | service_types | None | | subnetpool_id | None | | tags | None | | updated_at | None | | use_default_subnet_pool | None | +-------------------------+--------------------------------------+
Resetting the DHCP Agent
After resetting the "start" address in the subnet allocation pool, reset the DHCP agent so that it will have an IP address within the new range.
Delete the DHCP Port
1. Find the DHCP port for the affected network. Note that the IP address is in the original allocation pool range that preceded the resetting of the pool:
$ openstack port list --device-owner network:dhcp --network 46a25e07-54f1-4e19-a2e4-7681613e1d98 +--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+ | ID | Name | MAC Address | Fixed IP Addresses | Status | +--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+ | <port_UUID> | | fa:16:3e:35:3b:7e | ip_address='192.168.2.4', subnet_id='<subnet_UUID>' | ACTIVE | +--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+
2. Delete the port:
$ openstack port delete <port_UUID>
Reset the Agent
1. View the UUID of the DHCP agent, which you will need in the following step:
$ openstack network agent list --network <network_UUID> +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+ | ID | Agent Type | Host | Availability Zone | Alive | State | Binary | +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+ | <agent_UUID> | DHCP agent | <mcp_host_name> | None | :-) | UP | neutron-dhcp-agent | +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+
2. Remove the network from the agent:
$ openstack network agent remove network --dhcp <agent_UUID> <network_UUID>
3. Verify the removal of the network:
$ openstack network agent list --network <network_UUID>
The command returns no output.
4. Re-add the network to the agent:
$ openstack network agent add network --dhcp <agent_UUID> <network_UUID>
5. Confirm that the agent has been reattached to the network:
$ openstack network agent list --network <network_UUID> +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+ | ID | Agent Type | Host | Availability Zone | Alive | State | Binary | +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+ | <agent_UUID> | DHCP agent | <mcp_host_name> | None | :-) | UP | neutron-dhcp-agent | +--------------------------------------+------------+-------------------------------------+-------------------+-------+-------+--------------------+
6. Confirm that the agent is in service:
$ openstack network agent show <agent_UUID>
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| agent_type | DHCP agent |
| alive | :-) |
| availability_zone | None |
| binary | neutron-dhcp-agent |
| configuration | {u'subnets': 47, u'use_namespaces': True, u'dhcp_lease_duration': 14400, u'dhcp_driver': u'neutron.agent.linux.dhcp.Dnsmasq', u'networks': 48, u'log_agent_heartbeats': False, u'ports': 229} |
| created_at | 2016-11-16 23:16:47 |
| description | None |
| ha_state | None |
| host | <mcp_host_name> |
| id | <agent_UUID> |
| last_heartbeat_at | 2017-10-20 00:41:33 |
| name | None |
| started_at | 2017-10-12 23:36:34 |
| topic | dhcp_agent |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
7. View the new IP address of the agent. Note that it is within the "new" pool range.
$ openstack port list --device-owner network:dhcp --network <network_UUID>
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+
| <agent_UUID> | | fa:16:3e:17:bc:5f | ip_address='192.168.2.6', subnet_id='<subnet_UUID>' | ACTIVE |
+--------------------------------------+------+-------------------+----------------------------------------------------------------------------+--------+