Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property ACF::$fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields.php on line 138

Deprecated: Creation of dynamic property acf_loop::$loops is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 28

Deprecated: Creation of dynamic property ACF::$loop is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 269

Deprecated: Creation of dynamic property ACF::$revisions is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/revisions.php on line 397

Deprecated: Creation of dynamic property acf_validation::$errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 28

Deprecated: Creation of dynamic property ACF::$validation is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 214

Deprecated: Creation of dynamic property acf_form_customizer::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 28

Deprecated: Creation of dynamic property acf_form_customizer::$preview_fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 29

Deprecated: Creation of dynamic property acf_form_customizer::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 30

Deprecated: Creation of dynamic property ACF::$form_front is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-front.php on line 598

Deprecated: Creation of dynamic property acf_form_widget::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 34

Deprecated: Creation of dynamic property acf_form_widget::$preview_reference is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 35

Deprecated: Creation of dynamic property acf_form_widget::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 36

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the all-in-one-wp-migration domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp_plugin/wp_plugin.php on line 23

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1539

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 828

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the rocket domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property acf_field_oembed::$width is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 31

Deprecated: Creation of dynamic property acf_field_oembed::$height is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 32

Deprecated: Creation of dynamic property acf_field_google_map::$default_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-google-map.php on line 33

Deprecated: Creation of dynamic property acf_field__group::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-group.php on line 31

Deprecated: Creation of dynamic property acf_field_clone::$cloning is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 34

Deprecated: Creation of dynamic property acf_field_clone::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 35

Deprecated: Creation of dynamic property jh_acf_field_table::$settings is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-table-field/class-jh-acf-field-table.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902
{"id":24868,"date":"2019-09-23T13:06:16","date_gmt":"2019-09-23T10:06:16","guid":{"rendered":"https:\/\/upcloud.com\/community\/tutorials\/managing-floating-ips-upcloud-api"},"modified":"2019-09-23T13:06:16","modified_gmt":"2019-09-23T10:06:16","slug":"managing-floating-ips-upcloud-api","status":"publish","type":"tutorial","link":"https:\/\/studiogo.tech\/upcloudold\/tutorial\/managing-floating-ips-upcloud-api\/","title":{"rendered":"Managing floating IPs using the UpCloud API"},"content":{"rendered":"\n

Our SDN<\/a> enables a transferable IP address called a floating IP that can be used to build advanced availability and redundancy. Floating IP is a static public IPv4 address that can be attached to your cloud server. It directs traffic to one server at a time and can be moved between multiple servers in a blink of an eye.<\/p>\n\n\n\n

Using the UpCloud API for managing your floating IP addresses allows you to perform all necessary operations programmatically and automate failover. In this guide, we\u2019ll show you how to attach new floating IP addresses, transfer them on request, and delete the IPs once no longer needed.<\/p>\n\n\n\n

If you are not yet familiar with the UpCloud API, we would suggest taking a quick look at our guide to getting started with UpCloud API<\/a> to set up your API user account and access rights.<\/p>\n\n\n\n

\n
Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n

Attaching a new floating IP<\/h2>\n\n\n\n

When a new floating IP is created and attached, the target cloud server needs to be shut down.<\/p>\n\n\n\n

Begin by shutting down one of the cloud servers you wish to use the floating IP address. Only one of the servers must be shut down while a new floating IP is being attached.<\/p>\n\n\n\n

POST \/1.3\/server\/server_UUID<\/span>\/stop<\/pre>\n\n\n\n

Replace the IP address highlighted below in red<\/span> with the floating IP you wish to attach to a new cloud server then enter the MAC address of the network interface on the target. You can find the MAC address in your cloud server details by querying the API with the target UUID.<\/p>\n\n\n\n

GET \/1.3\/server\/server_uuid<\/span><\/pre>\n\n\n\n

Then create and attach a new IP address defined by setting the floating<\/tt> property as yes<\/tt>.<\/p>\n\n\n\n

POST \/1.3\/ip_address\n\n{\n  \"ip_address\": {\n    \"family\": \"IPv4\",\n    \"mac\": \"mm:mm:mm:mm:mm:m1<\/span>\",\n    \"floating\": \"yes\"\n  }\n}<\/pre>\n\n\n\n

You will also need to configure the floating IP at the operating system level. You can find instructions in our guides for CentOS<\/a>, Debian<\/a>, Ubuntu<\/a>, CoreOS<\/a> or Windows<\/a> on how to configure the floating IP on your servers.<\/p>\n\n\n\n

Transferring an existing floating IP<\/h2>\n\n\n\n

The advantage of a floating IP over regular IP addresses is the ability to transfer the IP from one server to another instantaneously. Depending on your use case, you might wish to move the floating IP address between servers at the time of your choosing or by configuring automation.<\/p>\n\n\n\n

Transferring a floating IP address using the UpCloud API is a simple task. While attaching a floating IP for the first time required the target cloud server to be shut down, transferring an existing address also works with running cloud servers.<\/p>\n\n\n\n

First, you need to know the network interface MAC address you wish to transfer the floating IP. You can find the MAC address in your cloud server details, for example, by querying the API with the target server\u2019s UUID.<\/p>\n\n\n\n

GET \/1.3\/server\/server_uuid<\/span><\/pre>\n\n\n\n

Then use the following command to transfer the floating IP. Replace the IP address highlighted below in red<\/span> with the floating IP address you wish to attach to a new cloud server then enter the MAC address of the network interface on the target.<\/p>\n\n\n\n

PATCH \/1.3\/ip_address\/0.0.0.0<\/span>\n\n{\n  \"ip_address\": {\n    \"mac\": \"mm:mm:mm:mm:mm:m1<\/span>\"\n  }\n}\n<\/pre>\n\n\n\n

If you haven\u2019t yet used the floating IP on the new cloud server, you will also need to configure the floating IP at the operating system level. You can find instructions in our guides for CentOS<\/a>, Debian<\/a>, Ubuntu<\/a>, CoreOS<\/a> or Windows<\/a> on how to configure the floating IP on your servers.<\/p>\n\n\n\n

It\u2019s also possible to do this directly from the target cloud server if, for example, it notices a failure in the current server the floating IP is pointing to.<\/p>\n\n\n\n

#!\/bin\/bash\n\n# Export your UpCloud credentials to the environmental variables\n# export UPCLOUD_USERNAME=username\n# export UPCLOUD_PASSWORD=password\n\n# Enter the floating ip address you want to attach\nip=0.0.0.0<\/span>\n# Select the target network interface, commonly eth0\ninterface=eth0<\/span>\n\n# API command to transfer the floating IP\ncurl -u \"$UPCLOUD_USERNAME:$UPCLOUD_PASSWORD\" -X PATCH \n-H Content-Type:application\/json https:\/\/api.upcloud.com\/1.3\/ip_address\/$ip \n--data-binary '{\"ip_address\":{\"mac\":\"'`cat \/sys\/class\/net\/$interface\/address`'\"}}'\n<\/pre>\n\n\n\n

Then execute the script whenever you need the floating IP transferred. This allows you to quickly redirect traffic or even automate failover.<\/p>\n\n\n\n

Detaching a floating IP<\/h2>\n\n\n\n

Detaching a floating IP without attaching it to another interface, pass an explicit null<\/tt> or empty string as a mac<\/tt> value.<\/p>\n\n\n\n

Replace the IP address highlighted below in red<\/span> with the floating IP you wish to detach.<\/p>\n\n\n\n

PATCH \/1.3\/ip_address\/0.0.0.0<\/span>\n\n{\n  \"ip_address\": {\n    \"mac\": null<\/span>\n  }\n}<\/pre>\n\n\n\n

Detaching a floating IP allows you to retain the IP address even if you wish to delete the servers it was used on. You might also wish to detach a floating IP while in use to stop traffic to the address in case of e.g. DDoS attack.<\/p>\n\n\n\n

Deleting a floating IP<\/h2>\n\n\n\n

Delete any IP address using the following command. Note that the deletion is permanent and cannot be reverted.<\/p>\n\n\n\n

Replace the IP address highlighted below in red<\/span> with the floating IP you wish to delete.<\/p>\n\n\n\n

DELETE \/1.3\/ip_address\/0.0.0.0<\/span><\/pre>\n\n\n\n

If you do delete an IP address by mistake, immediately attaching a new IP of the same type may give you the same IP that was just released if it has not been attached anywhere else.<\/p>\n","protected":false},"featured_media":27559,"comment_status":"open","ping_status":"closed","template":"","community-category":[109,111,122],"class_list":["post-24868","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry","community-category-upcloud-services","community-category-networking","community-category-api"],"acf":[],"_links":{"self":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial\/24868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/types\/tutorial"}],"replies":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/comments?post=24868"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media\/27559"}],"wp:attachment":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media?parent=24868"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/community-category?post=24868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}