CLI Tutorial: Public IPs (External Addresses) Swap

CLI Tutorial: Public IPs (External Addresses) Swap

Swapping public IPs is useful for routing incoming requests to the desired environment or application. This can be particularly beneficial when transitioning between testing and production environments.

The SwapExtIps CLI method enables you to exchange external IP addresses between two containers. If only one node has a public IP, it will be transferred to the second instance. This method can be applied to nodes within the same or different environments, but only within the confines of a single account.

As with most CLI operations, this can be accomplished with a single line of code:


~/jelastic/environment/binder/swapextips --envName {env_name} --sourceNodeId {source_node_id} --targetNodeId {target_node_id} [--sourceIp {source_ip}] [--targetIp {target_ip}]

Here, the following parameters should be specified:

  • {env_name}: The name of the environment where the external IP to be transferred is currently attached.
  • {source_node_id}: The identifier of the node from the specified environment whose IP should be swapped or moved.
  • {target_node_id}: The ID of the target node (which can belong to any environment on the account).
  • {source_ip} and {target_ip}: Optional parameters for specifying two specific addresses to be swapped. If these are not provided, all external IPs from the source node are transferred to the target node, and vice versa.

CLI configuration

Notes:

  1. Ensure that both the source and destination nodes (environments) are running before using the SwapExtIps CLI method.
  2. The process may cause short-term unavailability of the corresponding Public IP address(es) (up to 10 seconds).
  3. For swapping two specific addresses between nodes with multiple IPs on each one, please contact the Support Team for assistance, as support for such cases is currently under development.
  4. Automatic restart will occur for the following node types to start listening on the new addresses after the operation: GlassFish, Apache PHP, Apache Ruby, NGINX PHP, NGINX Ruby.
  5. For services like Elastic VPS and custom Docker containers, a manual restart may be required to adapt to the IP address change based on the comprised services.
  6. It’s recommended to recheck the Access via SLB state for both nodes after swapping IPs.

In a few moments, the IP addresses will be swapped between the specified nodes, and the operation details will be provided in the response.

Now that you’ve understood the concept of working with our CLI, you can proceed to automate environment management. For instance, you can create scripts for frequently used operation chains.

For a complete list of commands you can use, check out the platform’s API documentation.