In our architecture, direct attached dhcp IPs are in VLAN 201
neutron net-create dhcp-192-168-201 \ --shared --router:external false \ --provider:network_type vlan \ --provider:physical_network vlan \ --provider:segmentation_id 201
+---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | 1d0fc020-d33b-406e-a287-02032a5a09b0 | | mtu | 0 | | name | dhcp-192-168-201 | | port_security_enabled | True | | provider:network_type | vlan | | provider:physical_network | vlan | | provider:segmentation_id | 201 | | router:external | False | | shared | True | | status | ACTIVE | | subnets | | | tenant_id | e4cd3028bd484741a23bd2b17f3d368e | +---------------------------+--------------------------------------+
note down the id .. we need it in the command below
neutron subnet-create --allocation-pool start=192.168.201.5,end=192.168.201.250 \ --ip-version 4 --no-gateway --host-route destination=0.0.0.0/0,nexthop=192.168.201.1 \ --enable-dhcp --name dhcp-192-168-201 --dns-nameserver 8.8.8.8 \ 1d0fc020-d33b-406e-a287-02032a5a09b0 192.168.201.0/24
Created a new subnet: +-------------------+----------------------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------------------+ | allocation_pools | {"start": "192.168.201.5", "end": "192.168.201.250"} | | cidr | 192.168.201.0/24 | | dns_nameservers | 8.8.8.8 | | enable_dhcp | True | | gateway_ip | | | host_routes | {"destination": "0.0.0.0/0", "nexthop": "192.168.201.1"} | | id | c1330e34-c15a-4938-9561-01e569cf051f | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | dhcp-192-168-201 | | network_id | 1d0fc020-d33b-406e-a287-02032a5a09b0 | | subnetpool_id | | | tenant_id | e4cd3028bd484741a23bd2b17f3d368e | +-------------------+----------------------------------------------------------+
neutron net-list
+--------------------------------------+------------------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+------------------+-------------------------------------------------------+ | 1d0fc020-d33b-406e-a287-02032a5a09b0 | dhcp-192-168-201 | c1330e34-c15a-4938-9561-01e569cf051f 192.168.201.0/24 | +--------------------------------------+------------------+-------------------------------------------------------+
neutron subnet-list
+--------------------------------------+------------------+------------------+------------------------------------------------------+ | id | name | cidr | allocation_pools | +--------------------------------------+------------------+------------------+------------------------------------------------------+ | c1330e34-c15a-4938-9561-01e569cf051f | dhcp-192-168-201 | 192.168.201.0/24 | {"start": "192.168.201.5", "end": "192.168.201.250"} | +--------------------------------------+------------------+------------------+------------------------------------------------------+
Now you can select DHCP and get the IP directly to instance.