CLI Tutorial: Public IPs (External Addresses) Swap

The operation of Public IPs swap can come in handy for routing of the incoming requests to the required environment or application. This possibility may be especially useful when, for example, switching testing and production environments.

The appropriate CLI method gives you the ability to exchange external IP addresses between two nodes or, in case one of them doesn’t have the Public IP attached, just to move an address from one instance to another. Herewith, this can be handled for any nodes within the confines of a single user account, i.e. even for the ones, that belong to different environments or run different services. As usual, the operation requires just a single line of code for being executed:

~/jelastic/environment/binder/swapextips --envName {env_name} --srcnodeid {source_node_id} --dstnodeid {target_node_id}
Here, the following parameters should be specified:
  • {env_name} - name of the environment, where the transferred external IP is currently attached
  • {source_node_id} - identifier of the node from the stated environment, which IP should be swapped\moved
  • {target_node_id} - ID of the target node (can belong to any environment of an account)

CLI swap external IPs


  • this process may cause a short-term unavailability of the corresponding Public IP address(es) (up to 10 seconds)
  • nodes of the following types will be automatically restarted for the necessary changes to be applied: GlassFishApache-PHPApache-RubyNGINX-PHPNGINX-Ruby. This is required for forcing the corresponding services to start listening on new addresses
  • if operating with VPS or Docker containers, you need to handle the necessity of the appropriate instance restart by yourself (i.e. to perform it manually if needed), as it depends on a particular service, running inside. In such a way, you can be sure that the operation of IPs swap won’t result in the unrequired downtime of your application.

In a few minutes the operation will be finished and your IPs will be either exchanged or moved (like in the image above) between nodes within your account, whilst the details on the newly applied parameters will be provided in the response output.

Now, as you caught the idea on how to work with our CLI, you can proceed to automation of your environments’ management through building the frequently used operations’ chains by means of writing and applying the corresponding scripts.

The full information on all of the available commands and methods can be found within the Jelastic API documentation.