Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Managing floating IP addresses
In addition to having a private, fixed IP address, VM instances can have a public, or floating IP address to communicate with other networks. The information in this section describes how to create and manage floating IPs with the Red Hat OpenStack Services on OpenShift (RHOSO) Networking service (neutron).
This section contains the following topics:
3.1. Assigning a specific floating IP Copier lienLien copié sur presse-papiers!
You can assign a specific floating IP address to a VM instance in a Red Hat OpenStack Services on OpenShift (RHOSO) environment.
Prerequisites
-
The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. The
python-openstackclientpackage resides on your workstation.dnf list installed python-openstackclient
$ dnf list installed python-openstackclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Confirm that the system
OS_CLOUDvariable is set for your cloud:echo $OS_CLOUD
$ echo $OS_CLOUD my_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reset the variable if necessary:
export OS_CLOUD=my_other_cloud
$ export OS_CLOUD=my_other_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow As an alternative, you can specify the cloud name by adding the
--os-cloud <cloud_name>option each time you run anopenstackcommand.Assign a floating IP address to an instance.
- Example
In this example, the floating IP
192.0.2.200is being assigned to theprod-serv1instance.openstack server add floating ip prod-serv1 192.0.2.200
$ openstack server add floating ip prod-serv1 192.0.2.200Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Confirm that your floating IP is associated with your instance.
- Example
openstack server show prod-serv1
$ openstack server show prod-serv1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Sample output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Creating floating IP pools Copier lienLien copié sur presse-papiers!
You can use floating IP addresses to direct ingress network traffic to your Red Hat OpenStack Services on OpenShift (RHOSO) instances. First, you must define a pool of routable external IP addresses, which you can then assign to instances dynamically. The RHOSO Networking service (neutron) routes all incoming traffic destined for that floating IP to the instance that you associate with the floating IP.
The Networking service allocates floating IP addresses to all projects (tenants) from the same IP ranges in CIDR format. As a result, all projects can consume floating IPs from every floating IP subnet. You can manage this behavior using quotas for specific projects. For example, you can set the default to 10 for ProjectA and ProjectB, while setting the quota for ProjectC to 0.
Prerequisites
-
The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. The
python-openstackclientpackage resides on your workstation.dnf list installed python-openstackclient
$ dnf list installed python-openstackclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Confirm that the system
OS_CLOUDvariable is set for your cloud:echo $OS_CLOUD
$ echo $OS_CLOUD my_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reset the variable if necessary:
export OS_CLOUD=my_other_cloud
$ export OS_CLOUD=my_other_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow As an alternative, you can specify the cloud name by adding the
--os-cloud <cloud_name>option each time you run anopenstackcommand.When you create an external subnet, you can also define the floating IP allocation pool.
- Example
In this example, an external subnet,
public, is created with an allocation pool that starts with192.168.100.20, and ends with192.168.100.100. DHCP allocation is disabled becausepublichosts only floating IP addresses:openstack subnet create --no-dhcp \ --allocation-pool start=192.168.100.20,end=192.168.100.100 \ --gateway 192.168.100.1 --network 192.168.100.0/24 public
$ openstack subnet create --no-dhcp \ --allocation-pool start=192.168.100.20,end=192.168.100.100 \ --gateway 192.168.100.1 --network 192.168.100.0/24 publicCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
Confirm that the pool is configured properly by assigning a random floating IP to an instance.
For more information, see Assigning a random floating IP.
3.3. Assigning a random floating IP Copier lienLien copié sur presse-papiers!
You can dynamically allocate floating IP addresses to VM instances in your Red Hat OpenStack Services on OpenShift (RHOSO) environment from a pool of external IP addresses.
Prerequisites
-
The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. The
python-openstackclientpackage resides on your workstation.dnf list installed python-openstackclient
$ dnf list installed python-openstackclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow A pool of routable external IP addresses.
For more information, see Section 3.2, “Creating floating IP pools”.
Procedure
Confirm that the system
OS_CLOUDvariable is set for your cloud:echo $OS_CLOUD
$ echo $OS_CLOUD my_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reset the variable if necessary:
export OS_CLOUD=my_other_cloud
$ export OS_CLOUD=my_other_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow As an alternative, you can specify the cloud name by adding the
--os-cloud <cloud_name>option each time you run anopenstackcommand.Randomly allocate a floating IP address from the pool.
- Example
In this example, a floating IP address is randomly allocated from a network named
public.openstack floating ip create public
$ openstack floating ip create publicCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Sample output
In the following example, the newly allocated floating IP is
192.0.2.200. You can now assign the floating IP to an instance.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Enter the following command to locate your instance:
openstack server list
$ openstack server listCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Sample output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Associate the instance name or ID with the floating IP.
- Example
openstack server add floating ip prod-serv1 192.0.2.200
$ openstack server add floating ip prod-serv1 192.0.2.200Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Enter the following command to confirm that your floating IP is associated with your instance.
- Example
openstack server show prod-serv1
$ openstack server show prod-serv1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Sample output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4. Creating port forwarding for a floating IP Copier lienLien copié sur presse-papiers!
You can use the Red Hat OpenStack Services on OpenShift (RHOSO) Networking service (neutron) to set up port forwarding for a floating IP (FIP).
You cannot deploy FIP port fowarding and distributed FIP management on a router (ovn-router) if any network connected to the router uses VLAN or Flat tenant network types.
If you have one of those configurations, choose a workaround:
- Use Geneve or VXLAN network types instead of VLAN or Flat.
Disable distribute FIP management to use centralized FIP management:
enable_distributed_floating_ip = False
enable_distributed_floating_ip = FalseCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Prerequisites
-
The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. The
python-openstackclientpackage resides on your workstation.dnf list installed python-openstackclient
$ dnf list installed python-openstackclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow Your administrator has enabled the Networking service with the
port_forwardingservice plug-in.For information, see Configuring floating IP port forwarding in Configuring networking services.
Procedure
Confirm that the system
OS_CLOUDvariable is set for your cloud:echo $OS_CLOUD
$ echo $OS_CLOUD my_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reset the variable if necessary:
export OS_CLOUD=my_other_cloud
$ export OS_CLOUD=my_other_cloudCopy to Clipboard Copied! Toggle word wrap Toggle overflow As an alternative, you can specify the cloud name by adding the
--os-cloud <cloud_name>option each time you run anopenstackcommand.Use the following command to create port forwarding for a floating IP:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<internal-ip-address>with the internal, destination IP address.This is the IP address that is associated with the instance on which the application is running.
-
Replace
<port>with the name or ID of the Networking service port to which the instance is attached. Replace
<port-number>in--internal-protocol-portwith the internal, destination port number.This is the port number that the application running in the instance uses.
Replace
<port-number>in--external-protocol-portwith the external, source port number.This is the port number that the application running outside of your RHOSP cloud uses.
-
Replace
<protocol>with the protocol, such as TCP or UDP, used by the application that receives the port-forwarded traffic. Replace
<floating-ip>with the floating IP whose specified port traffic you want to forward.- Example
This example creates port forwarding for an instance that is attached to the floating IP
198.51.100.47. The floating IP uses the Networking service port1adfdb09-e8c6-4708-b5aa-11f50fc22d62. When the Networking service detects incoming, external traffic addressed to198.51.100.47:80, it forwards the traffic to the internal IP address,203.0.113.107, on TCP port,8080:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Confirm that the Networking service has established forwarding for the floating IP port.
- Example
The following example verifies successful port forwarding for the floating IP
198.51.100.47:openstack floating ip port forwarding list 198.51.100.47 \ -c "Internal Port ID" -c "Internal IP Address" -c "Internal Port" \ -c "External Port" --max-width 74
$ openstack floating ip port forwarding list 198.51.100.47 \ -c "Internal Port ID" -c "Internal IP Address" -c "Internal Port" \ -c "External Port" --max-width 74Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Sample output
The output shows that traffic sent to the floating IP
198.51.100.47on TCP port 80 is forwarded to port8080on the instance with the internal address203.0.113.107:Copy to Clipboard Copied! Toggle word wrap Toggle overflow