Exercise 1
Create a Topology using Neutron CLI Commands as per the below diagram,
Remarks : This is very basic exercise. This exercise demonstrates the Creation of Network, Subnet, Router, VM Creation with DHCP and VM Creation with Fixed IP.
Keypoints:
- VM1 gets IP from DHCP, VM2 have Static IP(To create a static IP, create a port with IP and associate with VM NIC).
- Router Interface is 10.10.10.1(default ip).
- Public Network and Floating IP details are depends on your environment.
Tests to be done:
- SSH to VM2 via Floating IP
- Ping to google.com from VM2
- Ping to VM1
Solution:
1. Network and Router Creation:
In my setup, External Network name is "public", 172.24.4.0/24
Create a N1 network
neutron net-create N1
Create a Subnet
Note: DHCP Pool is 10.10.10.10 to 10.10.10.50, gateway IP is : 10.10.10.1(Router IP)
neutron subnet-create --name S1 --gateway 10.10.10.1 --allocation-pool start=10.10.10.10,end=10.10.10.50 N1 10.10.10.0/24
Create a Router
neutron router-create Router1
Set the Gateway to the Router Router1
neutron router-gateway-set Router1 public
Attach the S1 subnet interface in to the Router Router1
neutron router-interface-add Router1 S1
To see the router in detail and ports
neutron router-show Router1
neutron router-port-list Router1
2. VM Creation:
List the images, flavors, keypairs and security-groups for selection.
nova keypair-list
glance image-list
nova flavor-list
neutron security-group-list
keypair : testkey, image : ubuntu14, flavor: 6, security-groups: default.
Create a VM1
nova boot --flavor 6 --image ubuntu14 --key-name testkey --security-groups default --nic net-name=N1 VM1
Note: VM1 takes IP from the DHCP Server(DHCP Pool)
Create a Port with IP 10.10.10.100 for VM2
neutron port-create --fixed-ip subnet_id=S1,ip_address=10.10.10.100 --security-group default N1
Create a VM2 with the Port created on last step:
nova boot --flavor 6 --image ubuntu14 --key-name testkey --security-groups default --nic port-id
=5c089b45-bdf3-4825-b71b-cc7a31eb325d VM2
To see the created VMs
nova list
3. Floating IP Creation & Association :
To create a floating ip:
neutron floatingip-create public
Identify the port id number associated with the VM1 IP:
neutron port-list
Note down the port id of the VM1.
Associate the floating ip to the port:
neutron floatingip-associate 110f5f61-1f30-4ad6-8aca-40bfcf485af4 f69ae0ee-f8ca-4349-890c-5347404528e9
Thats all. we successfully created the topology.
The detailed execution steps with logs are available in Execution Logs section.
4. Testing :
As, my external network is routable from the compute node, I am SSH to the VM2 FloatingIP from the compute node.
ssh -i testkey [email protected]
ping 10.10.10.12
pint 10.10.10.100
ping google.com
Execution Logs:
1. Network and Router Creation:
(osclient)cloud@db:~/osclient$ neutron net-create N1
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new network:
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2017-08-17T08:04:11Z |
| description | |
| id | 51c277c7-5c48-4181-afad-d370c6bc5752 |
| ipv4_address_scope | |
| ipv6_address_scope | |
| mtu | 1450 |
| name | N1 |
| port_security_enabled | True |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 3 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T08:04:11Z |
+-------------------------+--------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron subnet-create --name S1 --gateway 10.10.10.1 --allocation-pool start=10.10.10.10,end=10.10.10.50 N1 10.10.10.0/24
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new subnet:
+-------------------+------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------+
| allocation_pools | {"start": "10.10.10.10", "end": "10.10.10.50"} |
| cidr | 10.10.10.0/24 |
| created_at | 2017-08-17T08:07:12Z |
| description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 10.10.10.1 |
| host_routes | |
| id | 170fe9dc-ad2f-4332-9a71-42a01c15ec91 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | S1 |
| network_id | 51c277c7-5c48-4181-afad-d370c6bc5752 |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 2 |
| service_types | |
| subnetpool_id | |
| tags | |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T08:07:12Z |
+-------------------+------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron router-create Router1
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new router:
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2017-08-17T08:08:39Z |
| description | |
| external_gateway_info | |
| flavor_id | |
| id | c1055bf9-3ecc-40b0-af58-80d39497d0ca |
| name | Router1 |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 3 |
| routes | |
| status | ACTIVE |
| tags | |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T08:08:39Z |
+-------------------------+--------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron router-gateway-set Router1 public
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Set gateway for router Router1
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron router-interface-add Router1 S1
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Added interface 2487ef4f-0fbf-44de-bc60-60bac06a7aa4 to router Router1.
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron router-show Router1 --fit-width
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+-------------------------+---------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------+---------------------------------------------------------------------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | nova |
| created_at | 2017-08-17T08:08:39Z |
| description | |
| external_gateway_info | {"network_id": "975dd3d1-3576-4c34-991e-eaf24f45295e", "enable_snat": true, "external_fixed_ips": |
| | [{"subnet_id": "543ef8a3-5717-44d1-81f9-70c5057e889c", "ip_address": "172.24.4.3"}, {"subnet_id": |
| | "8171e8c6-2953-4ffa-beab-8f07b43a08c4", "ip_address": "2001:db8::1"}]} |
| flavor_id | |
| id | c1055bf9-3ecc-40b0-af58-80d39497d0ca |
| name | Router1 |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 7 |
| routes | |
| status | ACTIVE |
| tags | |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T08:11:05Z |
+-------------------------+---------------------------------------------------------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron router-port-list Router1 --fit-width
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+------+-------------------+-------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-------------------------------------------------+
| 2487ef4f-0fbf-44de-bc60-60bac06a7aa4 | | fa:16:3e:d4:eb:08 | {"subnet_id": "170fe9dc- |
| | | | ad2f-4332-9a71-42a01c15ec91", "ip_address": |
| | | | "10.10.10.1"} |
+--------------------------------------+------+-------------------+-------------------------------------------------+
(osclient)cloud@db:~/osclient$
2. VM Creation:
(osclient)cloud@db:~/osclient$ glance image-list
+--------------------------------------+---------------------------------+
| ID | Name |
+--------------------------------------+---------------------------------+
| 04733b2b-70aa-4bc3-a320-49e69d452ab6 | cirros-0.3.4-x86_64-uec |
| ad6f8bc1-b89e-49fc-b792-b54cd0986b91 | cirros-0.3.4-x86_64-uec-kernel |
| 60efae75-b0d5-406f-8e0c-c356e38a9455 | cirros-0.3.4-x86_64-uec-ramdisk |
| eb570c2e-46e2-4cc3-928a-fe5cdffa7822 | ubuntu14 |
+--------------------------------------+---------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True |
| 42 | m1.nano | 64 | 0 | 0 | | 1 | 1.0 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |
| 6 | m1.tiny2 | 1024 | 4 | 0 | | 1 | 1.0 | True |
| 84 | m1.micro | 128 | 0 | 0 | | 1 | 1.0 | True |
| c1 | cirros256 | 256 | 0 | 0 | | 1 | 1.0 | True |
| d1 | ds512M | 512 | 5 | 0 | | 1 | 1.0 | True |
| d2 | ds1G | 1024 | 10 | 0 | | 1 | 1.0 | True |
| d3 | ds2G | 2048 | 10 | 0 | | 2 | 1.0 | True |
| d4 | ds4G | 4096 | 20 | 0 | | 4 | 1.0 | True |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
(osclient)cloud@db:~/osclient$ nova keypair-list
+---------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+---------+------+-------------------------------------------------+
| mykey1 | ssh | a3:3b:f6:48:9a:e9:94:97:0c:dd:7d:57:fb:3d:2b:5c |
| testkey | ssh | 34:33:a3:a5:a7:ad:3e:90:65:6a:b7:0c:4f:d6:0a:6b |
+---------+------+-------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron security-group-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+---------+--------------------------------------------------+
| id | name | security_group_rules |
+--------------------------------------+---------+--------------------------------------------------+
| 8e4fe562-e310-443f-9534-f327418133a0 | test | egress, IPv4 |
| bffcafe4-3baa-49f7-836e-2bf335d4f366 | default | egress, IPv4, icmp, remote_ip_prefix: 0.0.0.0/0 |
| | | egress, IPv4, tcp, remote_ip_prefix: 0.0.0.0/0 |
| | | egress, IPv4, udp, remote_ip_prefix: 0.0.0.0/0 |
| | | ingress, IPv4, icmp, remote_ip_prefix: 0.0.0.0/0 |
| | | ingress, IPv4, tcp, remote_ip_prefix: 0.0.0.0/0 |
| | | ingress, IPv4, udp, remote_ip_prefix: 0.0.0.0/0 |
+--------------------------------------+---------+--------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ nova boot --flavor 6 --image ubuntu14 --key-name testkey --security-groups default --nic[2/1979]
e=N1 VM1
+--------------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------------+-------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | E7WaMb3QDaSw |
| config_drive | |
| created | 2017-08-17T09:12:47Z |
| description | - |
| flavor | m1.tiny2 (6) |
| hostId | |
| id | c149d99e-4231-423f-9698-c853810198e2 |
| image | ubuntu14 (eb570c2e-46e2-4cc3-928a-fe5cdffa7822) |
| key_name | testkey |
| locked | False |
| metadata | {} |
| name | VM1 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tags | [] |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated | 2017-08-17T09:12:47Z |
| user_id | 9b2d58dc14b2456fa5b7e5adae366f04 |
+--------------------------------------+-------------------------------------------------+
(osclient)cloud@db:~/osclient$ nova list
+--------------------------------------+------+--------+------------+-------------+----------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+----------------+
| c149d99e-4231-423f-9698-c853810198e2 | VM1 | ACTIVE | - | Running | N1=10.10.10.12 |
+--------------------------------------+------+--------+------------+-------------+----------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron port-create --fixed-ip subnet_id=S1,ip_address=10.10.10.100 --security-group default N1
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new port:
+-----------------------+-------------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+-------------------------------------------------------------------------------------+
| admin_state_up | True |
| allowed_address_pairs | |
| binding:vnic_type | normal |
| created_at | 2017-08-17T09:16:02Z |
| description | |
| device_id | |
| device_owner | |
| extra_dhcp_opts | |
| fixed_ips | {"subnet_id": "170fe9dc-ad2f-4332-9a71-42a01c15ec91", "ip_address": "10.10.10.100"} |
| id | 5c089b45-bdf3-4825-b71b-cc7a31eb325d |
| mac_address | fa:16:3e:ef:cf:51 |
| name | |
| network_id | 51c277c7-5c48-4181-afad-d370c6bc5752 |
| port_security_enabled | True |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 5 |
| security_groups | bffcafe4-3baa-49f7-836e-2bf335d4f366 |
| status | DOWN |
| tags | |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T09:16:02Z |
+-----------------------+-------------------------------------------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ nova boot --flavor 6 --image ubuntu14 --key-name testkey --security-groups default --nic port-id
=5c089b45-bdf3-4825-b71b-cc7a31eb325d VM2
+--------------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------------+-------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | wuFk8uUCM6Hg |
| config_drive | |
| created | 2017-08-17T09:18:08Z |
| description | - |
| flavor | m1.tiny2 (6) |
| hostId | |
| id | b1ccbc96-9d6d-48a8-a45f-dfa0e6bacb7b |
| image | ubuntu14 (eb570c2e-46e2-4cc3-928a-fe5cdffa7822) |
| key_name | testkey |
| locked | False |
| metadata | {} |
| name | VM2 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tags | [] |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated | 2017-08-17T09:18:08Z |
| user_id | 9b2d58dc14b2456fa5b7e5adae366f04 |
+--------------------------------------+-------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ nova list
+--------------------------------------+------+--------+------------+-------------+-----------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+-----------------+
| c149d99e-4231-423f-9698-c853810198e2 | VM1 | ACTIVE | - | Running | N1=10.10.10.12 |
| b1ccbc96-9d6d-48a8-a45f-dfa0e6bacb7b | VM2 | ACTIVE | - | Running | N1=10.10.10.100 |
+--------------------------------------+------+--------+------------+-------------+-----------------+
(osclient)cloud@db:~/osclient$
3. Floating IP Creation & Association :
(osclient)cloud@db:~/osclient$ neutron floatingip-create public
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2017-08-17T09:29:17Z |
| description | |
| fixed_ip_address | |
| floating_ip_address | 172.24.4.2 |
| floating_network_id | 975dd3d1-3576-4c34-991e-eaf24f45295e |
| id | 110f5f61-1f30-4ad6-8aca-40bfcf485af4 |
| port_id | |
| project_id | bccf45eee4544264a526c4bca56fdb3c |
| revision_number | 1 |
| router_id | |
| status | DOWN |
| tenant_id | bccf45eee4544264a526c4bca56fdb3c |
| updated_at | 2017-08-17T09:29:17Z |
+---------------------+--------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron floatingip-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+------------------+---------------------+---------+
| id | fixed_ip_address | floating_ip_address | port_id |
+--------------------------------------+------------------+---------------------+---------+
| 110f5f61-1f30-4ad6-8aca-40bfcf485af4 | | 172.24.4.2 | |
| dcb48f7f-cb4c-4289-a27b-62b4e3399647 | | 172.24.4.12 | |
+--------------------------------------+------------------+---------------------+---------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron port-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------------------------------+
| 2487ef4f-0fbf-44de-bc60-60bac06a7aa4 | | fa:16:3e:d4:eb:08 | {"subnet_id": "170fe9dc-ad2f-4332-9a71-42a01c15ec91", "ip_address": "10.10.10.1"} |
| 4ff4aaca-3b24-4a22-883f-ea218196ff6d | | fa:16:3e:fb:cc:fe | {"subnet_id": "91c773a1-a4e2-4f14-946d-401c1f7ee627", "ip_address": "10.0.0.2"} |
| | | | {"subnet_id": "dea60d2b-6809-43eb-a687-d1877e04f679", "ip_address": "fd25:cc32:b8d7:0:f816:3eff:fefb:ccfe"} |
| 5c089b45-bdf3-4825-b71b-cc7a31eb325d | | fa:16:3e:ef:cf:51 | {"subnet_id": "170fe9dc-ad2f-4332-9a71-42a01c15ec91", "ip_address": "10.10.10.100"} |
| db88c33a-9549-4d91-b218-f06ecb2aa57c | | fa:16:3e:8a:ca:fc | {"subnet_id": "170fe9dc-ad2f-4332-9a71-42a01c15ec91", "ip_address": "10.10.10.10"} |
| f69ae0ee-f8ca-4349-890c-5347404528e9 | | fa:16:3e:2f:53:56 | {"subnet_id": "170fe9dc-ad2f-4332-9a71-42a01c15ec91", "ip_address": "10.10.10.12"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------------------------------+
(osclient)cloud@db:~/osclient$ neutron floatingip-associate 110f5f61-1f30-4ad6-8aca-40bfcf485af4 f69ae0ee-f8ca-4349-890c-5347404528e9
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Associated floating IP 110f5f61-1f30-4ad6-8aca-40bfcf485af4
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ nova list
+--------------------------------------+------+--------+------------+-------------+----------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+----------------------------+
| c149d99e-4231-423f-9698-c853810198e2 | VM1 | ACTIVE | - | Running | N1=10.10.10.12, 172.24.4.2 |
| b1ccbc96-9d6d-48a8-a45f-dfa0e6bacb7b | VM2 | ACTIVE | - | Running | N1=10.10.10.100 |
+--------------------------------------+------+--------+------------+-------------+----------------------------+
(osclient)cloud@db:~/osclient$
4. Testing :
cloud@dev1:~$ ssh -i testkey [email protected]
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-126-generic x86_64)
ubuntu@vm1:~$
ubuntu@vm1:~$ ping 10.10.10.12
PING 10.10.10.12 (10.10.10.12) 56(84) bytes of data.
64 bytes from 10.10.10.12: icmp_seq=1 ttl=64 time=0.270 ms
^C
--- 10.10.10.12 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.270/0.270/0.270/0.000 ms
ubuntu@vm1:~$ ping 10.10.10.100
PING 10.10.10.100 (10.10.10.100) 56(84) bytes of data.
64 bytes from 10.10.10.100: icmp_seq=1 ttl=64 time=1.78 ms
^C
--- 10.10.10.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.788/1.788/1.788/0.000 ms
ubuntu@vm1:~$ ping google.com
PING google.com (172.217.19.238) 56(84) bytes of data.
64 bytes from par21s11-in-f14.1e100.net (172.217.19.238): icmp_seq=1 ttl=56 time=3.69 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/ma