Bookmark this page

Guided Exercise: Managing Routers and Floating IPs

In this exercise, you will create and configure a router using the command line and the Dashboard, and create a set of floating IP addresses and allocate them to an instance.

Outcomes

You should be able to:

  • Create and manage a router.

  • Verify the connectivity of the router.

  • Create and manage floating IP addresses.

  • Verify the external connectivity of an instance.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command ensures that all resources required for the exercise are present.

[student@workstation ~]$ lab public-routers start

Procedure 7.2. Instructions

This guided exercise is in two parts. In part 1 you use the CLI, and in part 2 you use the Dashboard.

  1. As the developer1 user in the finance project, create a new router and verify the resources. Use the values in the following table:

    SettingRouter
    Router Name finance-router1
    External network provider-datacentre
    Network subnet finance-subnet3
    1. On workstation, source the identity environment file for the developer1 user in the finance project.

      [student@workstation ~]$ source ~/developer1-finance-rc
    2. Use the openstack router create command to create the finance-router1 router.

      [student@workstation ~(developer1-finance)]$ openstack router create \
      > finance-router1
      +-------------------------+------------------------------------------------------+
      | Field                   | Value                                                |
      +-------------------------+------------------------------------------------------+
      | admin_state_up          | UP                                                   |
      | availability_zone_hints | None                                                 |
      | availability_zones      | None                                                 |
      | created_at              | 2020-07-14T16:00:45Z                                 |
      | description             |                                                      |
      | external_gateway_info   | null                                                 |
      | flavor_id               | None                                                 |
      | id                      | 6ea98144-c243-41cc-8064-c8281821c6d0                 |
      | location                | cloud='', project.domain_id=,                        |
      |                         | project.domain_name='Example',                       |
      |                         | project.id='f76fd09fa0b14a678b5b61f9e3ec3c87',       |
      |                         | project.name='finance', region_name='regionOne',     |
      |                         | zone=                                                |
      | name                    | finance-router1                                      |
      | project_id              | f76fd09fa0b14a678b5b61f9e3ec3c87                     |
      | revision_number         | 0                                                    |
      | routes                  |                                                      |
      | status                  | ACTIVE                                               |
      | tags                    |                                                      |
      | updated_at              | 2020-07-14T16:00:45Z                                 |
      +-------------------------+------------------------------------------------------+
    3. List the available routers to confirm that the finance-router1 has been created.

      [student@workstation ~(developer1-finance)]$ openstack router list
      +--------------------+-----------------+--------+-------+---------------------+
      | ID                 | Name            | Status | State | Project             |
      +--------------------+-----------------+--------+-------+---------------------+
      | 6ea98144-c243-41cc | finance-router1 | ACTIVE | UP    | f76fd09fa0b14a678b5 |
      | -8064-c8281821c6d0 |                 |        |       | b61f9e3ec3c87       |
      +--------------------+-----------------+--------+-------+---------------------+
    4. Connect the router to the finance-subnet3 subnet.

      [student@workstation ~(developer1-finance)]$ openstack router add subnet \
      > finance-router1 finance-subnet3
    5. Set the external network provider-datacentre as the gateway for the router.

      [student@workstation ~(developer1-finance)]$ openstack router set \
      > --external-gateway provider-datacentre \
      > finance-router1
  2. Test the routing from finance-server1.

    1. Retrieve the console URL for the finance-server1 instance.

      [student@workstation ~(developer1-finance)]$ openstack console url show \
      > finance-server1
      +-------+------------------------------------------------------------------------+
      | Field | Value                                                                  |
      +-------+------------------------------------------------------------------------+
      | type  | novnc                                                                  |
      | url   | http://172.25.250.50:6080/vnc_auto.html?path=%3Ftoken%3Df541d3ea-      |
      |       | af9b-4e6c-9881-a9604a9e87e1                                            |
      +-------+------------------------------------------------------------------------+
    2. Open a browser and navigate to the console URL previously obtained.

    3. Log in to finance-server1 using root as the user name and redhat as the password.

    4. Use the ping command to verify workstation server connectivity.

      [root@finance-server1 ~]# ping -c3 workstation
      PING workstation (172.25.250.9) 56(84) bytes of data.
      64 bytes from workstation.lab.example.com (172.25.250.9): icmp_seq=1 ttl=63 time=2.48 ms
      64 bytes from workstation.lab.example.com (172.25.250.9): icmp_seq=2 ttl=63 time=2.82 ms
      64 bytes from workstation.lab.example.com (172.25.250.9): icmp_seq=3 ttl=63 time=1.31 ms
      
      --- workstation ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 9ms
      rtt min/avg/max/mdev = 1.310/2.203/2.817/0.646 ms
    5. Log out from finance-server1.

      [root@finance-server1 ~]# logout
  3. In the workstation terminal, associate a floating IP address to the finance-server1 instance and verify it.

    1. Use the openstack floating ip create command to create one floating IP address in the provider-datacentre external network.

      Note

      Your floating IP address may differ from the one shown below.

      [student@workstation ~(developer1-finance)]$ openstack floating ip create \
      > provider-datacentre
      +---------------------+----------------------------------------------------------+
      | Field               | Value                                                    |
      +---------------------+----------------------------------------------------------+
      | created_at          | 2020-07-14T16:48:40Z                                     |
      | description         |                                                          |
      | dns_domain          |                                                          |
      | dns_name            |                                                          |
      | fixed_ip_address    | None                                                     |
      | floating_ip_address | 172.25.250.125                                           |
      | floating_network_id | ef95203b-7c9f-46c0-b328-e51aa7729798                     |
      | id                  | cda15c6c-3325-49f5-a05a-740761aec953                     |
      | location            | Munch({'cloud': '', 'region_name': 'regionOne', 'zone':  |
      |                     | None, 'project': Munch({'id':                            |
      |                     | 'f76fd09fa0b14a678b5b61f9e3ec3c87', 'name': 'finance',   |
      |                     | 'domain_id': None, 'domain_name': 'Example'})})          |
      | name                | 172.25.250.125                                           |
      | port_details        | None                                                     |
      | port_id             | None                                                     |
      | project_id          | f76fd09fa0b14a678b5b61f9e3ec3c87                         |
      | qos_policy_id       | None                                                     |
      | revision_number     | 0                                                        |
      | router_id           | None                                                     |
      | status              | DOWN                                                     |
      | subnet_id           | None                                                     |
      | tags                | []                                                       |
      | updated_at          | 2020-07-14T16:48:40Z                                     |
      +---------------------+----------------------------------------------------------+
    2. Associate the floating IP address with the finance-server1 instance.

      [student@workstation ~(developer1-finance)]$ openstack server add floating ip \
      > finance-server1 172.25.250.125
    3. Verify that the floating IP address has been attached to the finance-server1 instance.

      [student@workstation ~(developer1-finance)]$ openstack server list \
      > -c Name -c Networks
      +-----------------+------------------------------------------------+
      | Name            | Networks                                       |
      +-----------------+------------------------------------------------+
      | finance-server2 | finance-network4=192.168.4.68                  |
      | finance-server1 | finance-network3=192.168.3.151, 172.25.250.125 |
      +-----------------+------------------------------------------------+
    4. Now you can log in using SSH to the finance-server1 instance from workstation.

      [student@workstation ~(developer1-finance)]$ ssh -i .ssh/example-keypair \
      > cloud-user@172.25.250.125
      Activate the web console with: systemctl enable --now cockpit.socket
      
      This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
      To register this system, run: insights-client --register
      
      Last login: Tue Jul 14 13:11:09 2020 from 172.25.250.9
      [cloud-user@finance-server1 ~]$
    5. Log out from finance-server1.

      [cloud-user@finance-server1 ~]$ logout
      Connection to 172.25.250.125 closed.
      [student@workstation ~(developer1-finance)]$
  4. Disassociate the floating IP address from the finance-server1 instance and release the floating IP address.

    1. Disassociate the 172.25.250.N floating IP address from the finance-server1 instance.

      Note

      Remember to use the floating IP address value from your output.

      [student@workstation ~(developer1-finance)]$ openstack server remove floating ip \
      > finance-server1 172.25.250.125
    2. Release the 172.25.250.N floating IP address.

      [student@workstation ~(developer1-finance)]$ openstack floating ip delete \
      > 172.25.250.125
    3. List the available floating IP addresses to confirm the deletion of 172.25.250.N.

      [student@workstation ~(developer1-finance)]$ openstack floating ip list
  5. Disconnect and remove the finance-router1 router.

    1. Disconnect the router from the finance-subnet3 subnet.

      [student@workstation ~(developer1-finance)]$ openstack router remove subnet \
      > finance-router1 finance-subnet3
    2. Remove the external provider-datacentre network as the gateway for the router.

      [student@workstation ~(developer1-finance)]$ openstack router unset \
      > --external-gateway finance-router1
    3. Delete the finance-router1 router.

      [student@workstation ~(developer1-finance)]$ openstack router delete \
      > finance-router1
    4. Verify that the finance-router1 router has been deleted.

      [student@workstation ~(developer1-finance)]$ openstack router list

      Note

      Use the Dashboard to perform the following steps.

  6. In the Dashboard as developer1, create a router and then verify the resources. Use the values in the following table:

    SettingRouter
    Router name finance-router2
    External network provider-datacentre
    Network subnet finance-subnet4
    1. Log in to the Dashboard at http://dashboard.overcloud.example.com using Example as the domain, developer1 as the user, and redhat as the password. Confirm that the selected project is finance.

    2. Navigate to ProjectNetworkRouters and click Create Router to create a new router.

    3. Enter finance-router2 as the router name. From the External Network list, select provider-datacentre and then click Create Router.

    4. Click the name of the router, finance-router2, to access its details. Click the Interfaces tab to manage the interfaces for the router.

    5. Click Add Interface to add a new interface. From the Subnet list, select finance-network4: 192.168.4.0/24 (finance-subnet4) as the subnet and click Submit.

    6. To verify the resources have been created, navigate to ProjectNetworkNetwork Topology.

  7. Create and associate a floating IP address with the finance-server2 instance.

    1. Navigate to ProjectNetworkFloating IPs and click Allocate IP To Project.

    2. Ensure that provider-datacentre is set as the Pool, and then click Allocate IP.

    3. Click Associate in the row of the floating IP address. When the Manage Floating IP Associations window opens, select finance-server2: 192.168.4.N from the Port to be associated list. Click Associate.

    4. Navigate to ProjectComputeInstances

    5. Review the IP Address column and notice the IP address for finance-server2.

  8. Disassociate the floating IP address from the finance-server2 instance and release the floating IP.

    1. Navigate to ProjectComputeInstances, and click the arrow next to the Create Snapshot button for the row labeled finance-server2.

    2. Select Disassociate Floating IP to disassociate the floating IP address from the instance. In the Disassociate Floating IP window, click Disassociate.

    3. Navigate to ProjectNetworkFloating IPs, and click the arrow next to the Associate button for the floating IP address row.

    4. Select Release Floating IP to return the floating IP address to the pool. In the Confirm Release Floating IP window, click Release Floating IP.

  9. Disconnect and delete the finance-router2 router.

    1. Navigate to ProjectNetworkRouters.

    2. Click the name of the router, finance-router2, to access its details. Click the Interfaces tab to manage the interfaces for the router.

    3. Click Delete Interface to remove the interface. In the Confirm Delete Interface window, click Delete Interface.

    4. Click Clear Gateway to remove the external provider-datacentre network as the gateway for the router. In the Confirm Clear Gateway window, click Clear Gateway.

    5. Click the arrow next to the Set Gateway button for the finance-router2 row, and then click Delete Router. In the Confirm Delete Router window, click Delete Router.

    6. Log out of the Dashboard by clicking the developer1 menu in the upper-right corner, and then choose Sign out.

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab public-routers finish

This concludes the guided exercise.

Revision: cl110-16.1-4c76154