To create the external network on controller
source /root/admin-openrc.sh
neutron net-create ext-net --shared --router:external=True
To create a subnet on the external network
neutron subnet-create ext-net --name ext-subnet --allocation-pool start=192.168.255.160,end=192.168.255.180 --disable-dhcp --gateway 192.168.255.2 ext_net 192.168.255.0/24
#To create the tenant network
source /root/demo-openrc.sh
#Create the network:
neutron net-create demo-net
#To create a subnet on the tenant network
neutron subnet-create demo-net --name demo-subnet --gateway 10.0.0.1 10.0.0.0/24
#Create the router:
neutron router-create demo-router
#Attach the router to the demo tenant subnet:
neutron router-interface-add demo-router demo-subnet
#Added interface b1a894fd-aee8-475c-9262-4342afdc1b58 to router demo-router.
neutron router-gateway-set demo-router ext-net
#Set gateway for router demo-router
Now check whether the gateway of the external-network here it will be 192.168.255.160 which is first Ip of the range. Try pinging to the IP and if its not working Stop there and remove all the routers and gateway and redo it using the ID. If the gate way Don't get pinged the instance won't be able to access outside the network.
Set the neutron router-interface-add and neutron router-gateway-set BY ID
neutron router-list
+--------------------------------------+-------------+--------------------------------------------------------+
| id | name | external_gateway_info |
+--------------------------------------+-------------+--------------------------------------------------------+
| 020f48d9-182e-4e33-a73f-813333533092 | router-demo | {"network_id": "9a457578-8f85-486b-9cd0-f7f04922ba0c"} |
+--------------------------------------+-------------+--------------------------------------------------------+
# neutron net-list
+--------------------------------------+----------+----------------------------------------------------+
| id | name | subnets |
+--------------------------------------+----------+----------------------------------------------------+
| 07e10f48-0637-46bb-a444-695646e6bd15 | net-demo | c042e65e-3892-45bc-aeb0-625ce5f4aaaf 50.50.1.0/24 |
| 9a457578-8f85-486b-9cd0-f7f04922ba0c | ext_net | 0bcccf59-be17-48c7-8032-e00fd4f15b46 1.2.3.0/24 |
+--------------------------------------+----------+----------------------------------------------------+
#neutron router-gateway-set 020f48d9-182e-4e33-a73f-813333533092 9a457578-8f85-486b-9cd0-f7f04922ba0c