{"id":406009,"date":"2022-02-15T23:57:33","date_gmt":"2022-02-15T20:57:33","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/"},"modified":"2022-02-15T23:57:33","modified_gmt":"2022-02-15T20:57:33","slug":"what-are-floating-ips-in-digitalocean-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/","title":{"rendered":"#What Are Floating IPs In DigitalOcean? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6aef72c5484d6\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6aef72c5484d6\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#Uses_for_Floating_IPs\" >Uses for Floating IPs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#Creating_Floating_IPs\" >Creating Floating IPs<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#With_the_API\" >With the API<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#Managing_Outbound_Traffic\" >Managing Outbound Traffic<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#Limitations\" >Limitations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-floating-ips-in-digitalocean-cloudsavvy-it\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What Are Floating IPs In DigitalOcean? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-8934\" data-pagespeed-lazy-srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/83680385.jpeg?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/83680385.jpeg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/83680385.jpeg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"DigitalOcean logo\" width=\"1600\" height=\"900\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>DigitalOcean\u2019s Floating IPs are a way of reserving public IP addresses that are independent of your compute resources. They provide a way to rapidly reroute traffic between your assets without waiting for DNS changes to take effect.<\/p>\n<p>Compute components such as Droplets come with their own IPv4 address that facilitates public access. When you destroy a Droplet, you lose your rights to its IP. That address will go back into the pool that\u2019s available to new Droplet creations.<\/p>\n<p>Floating IPs are yours for as long as you need them. Once you\u2019ve been allocated an IP, it can be attached to any eligible resource or sit dormant in your account for the future. Destroying a Droplet that\u2019s targeted by a floating IP will keep the address available in your account, removing only the Droplet-specific IP allocated at the time of the Droplet\u2019s creation.<\/p>\n<h2 id=\"uses-for-floating-ips\"><span class=\"ez-toc-section\" id=\"Uses_for_Floating_IPs\"><\/span>Uses for Floating IPs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Floating IP pattern lets you more closely mimic on-premises networking in the cloud. If you ran your own datacentre, you\u2019d get a block of IP addresses from your ISP that you could assign to a gateway router at the entrypoint to your network. You\u2019d then be free to change the infrastructure behind the router without changing the IP addresses that external users need to know.<\/p>\n<p>Floating IPs offer similar ease of use for the resources in your DigitalOcean account. Pointing your external DNS at a floating IP instead of a specific Droplet IP lets you replace individual Droplets while leaving DNS records alone.<\/p>\n<p>One common use case is failover scenarios in combination with high availability deployments. You can quickly route traffic away from a Droplet that\u2019s experiencing issues by switching the Floating IP to reference another target in your account. You can use the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.digitalocean.com\/reference\/api\/api-reference\/#tag\/Floating-IPs\">DigitalOcean API to<\/a> implement automated failovers by switching the target of a Floating IP when your monitoring service detects an outage.<\/p>\n<h2 id=\"creating-floating-ips\"><span class=\"ez-toc-section\" id=\"Creating_Floating_IPs\"><\/span>Creating Floating IPs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Floating IPs can be created via the DigitalOcean control panel or <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.digitalocean.com\/reference\/api\/api-reference\/#tag\/Floating-IPs\">the API<\/a>. You\u2019re initially limited to three floating IPs on your account; requests for more must be initiated through the control panel after you reach the cap.<\/p>\n<p>Addresses which are in active use are currently free of charge. You\u2019ll be billed at $4 per month or $0.00595 per hour if you create Floating IPs but leave them dormant in your account. This charge is <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>lied due to the global shortage of IPv4 addresses. You\u2019ll only be billed after your usage exceeds $1 so you don\u2019t need to worry about brief periods of detachment when creating and reassigning your addresses.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15510\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2022\/02\/ec98bfef.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1268\" height=\"648\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To create a floating IP, login to your control panel account and click the \u201cNetworking\u201d link in the left sidebar. Select the \u201cFloating IPs\u201d tab. Use the dropdown menu to choose the Droplet you want traffic to be routed to. Next, press the \u201cAssign Floating IP\u201d button to generate your new address.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15511\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2022\/02\/cd1df981.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1268\" height=\"648\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Requests made to this IP address will be routed to the selected Droplet. You can change the target by returning to the Floating IPs page, clicking the \u201cMore\u201d button next to your IP, and selecting either \u201cReassign\u201d or \u201cUnassign.\u201d Unassigning the IP will start accruing billing for the unused reservation.<\/p>\n<h3 id=\"with-the-api\"><span class=\"ez-toc-section\" id=\"With_the_API\"><\/span>With the API<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To create a floating IP with the DigitalOcean API, send a <code>POST<\/code> request to the <code>api.digitalocean.com\/v2\/floating_ips<\/code> endpoint. Refer to the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.digitalocean.com\/reference\/api\/api-reference\/#section\/Authentication\">documentation<\/a> to generate and supply correct access credentials for your account.<\/p>\n<p>The request needs to include a JSON payload identifying the Droplet to target:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"json\">\n<pre class=\"de1\">{&#13;\n    \"droplet_id\": 1234567890&#13;\n}<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>You can discover the IDs of all your droplets by making a <code>GET<\/code> request to the <code>api.digitalocean.com\/v2\/droplets<\/code> endpoint.<\/p>\n<p>To change the target of a floating IP you must use the special <code>actions<\/code> endpoint:<\/p>\n<pre>POST api.digitalocean.com\/v2\/floating_ips\/123.456.789.012\/actions<\/pre>\n<p>The floating IP needs to be identified by its IPv4 address, as shown in the URL above. Include a JSON payload that selects the <code>assign<\/code> action and specifies the droplet ID to target:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"json\">\n<pre class=\"de1\">{&#13;\n    \"droplet_id\": 1234567890,&#13;\n    \"type\": \"assign\"&#13;\n}<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>To unassign an IP, use the same endpoint but substitute <code>unassign<\/code> as the <code>type<\/code> field in your JSON payload. You can omit the <code>droplet_id<\/code> field.<\/p>\n<h2 id=\"managing-outbound-traffic\"><span class=\"ez-toc-section\" id=\"Managing_Outbound_Traffic\"><\/span>Managing Outbound Traffic<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Even with a Floating IP assigned, Droplets will still use their specific IP addresses for outbound traffic. This means external services such as third-party APIs will continue to identify your Droplet via its own IP address, instead of the Floating IP.<\/p>\n<p>You can make outbound traffic use the Floating IP instead by updating the routing table in the Droplet\u2019s networking configuration. Begin by using DigitalOcean\u2019s Metadata API from within the Droplet to discover its anchor IP address. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.digitalocean.com\/products\/networking\/floating-ips\/how-to\/find-anchor-ips\">Anchor IPs<\/a> are IP addresses through which traffic flows when <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/trip-and-travel\/\" data-internallinksmanager029f6b8e52c=\"10\" title=\"Trip &amp; Travel\" target=\"_blank\" rel=\"noopener\">travel<\/a>ing between the Droplet and its Floating IP.<\/p>\n<pre># Returns the Anchor IP of the Droplet this command is executed on&#13;\ncurl -s http:\/\/169.254.169.254\/metadata\/v1\/interfaces\/public\/0\/anchor_ipv4\/gateway<\/pre>\n<p>Next use the <code>ip route<\/code> command to modify your Droplet\u2019s default route:<\/p>\n<pre># Remove the existing default route (Droplet-specific IP)&#13;\nip route del 0\/0;&#13;\n&#13;\n# Set the Anchor IP as the new default route&#13;\nip route add default via &lt;anchor IP&gt; dev eth0<\/pre>\n<p>Now traffic originating from your Droplet will appear to come from its assigned Floating IP. This is useful when you\u2019re communicating with services that use automatically determined callback URLs to subsequently send confirmation back to your system. The procedure ensures the callback will be sent to the Floating IP that\u2019s currently exposing your Droplet.<\/p>\n<h2 id=\"limitations\"><span class=\"ez-toc-section\" id=\"Limitations\"><\/span>Limitations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Floating IPs are currently restricted to IPv4 addresses. DigitalOcean has not publicly announced any plan to offer IPv6 Floating IPs.<\/p>\n<p>As floating IPs are allocated to specific datacentre regions, they can only target Droplets within the same datacentre. A Floating IP in NYC1 can\u2019t be mapped to a Droplet in AMS1.<\/p>\n<p>Only Droplets can be the targets of your Floating IPs. It\u2019s not possible to reference a Managed Kubernetes Node or any other resource using one. In the case of Kubernetes, a Load Balancer is the closest alternative, letting you route traffic between your Nodes. Load Balancers come with their own public IP address and cannot be used as a Floating IP target either.<\/p>\n<p>All Floating IPs work with a single Droplet at a time \u2013 they can\u2019t be mapped to multiple Droplets simultaneously as they have no active routing component. They don\u2019t offer PTR records for reverse DNS either and cannot be used <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.digitalocean.com\/products\/networking\/floating-ips\/#limits\">for SMTP traffic<\/a>.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Floating IPs are a mechanism by which you can switch the targets of publicly-accessible static IP addresses in your DigitalOcean account. The floating IP itself will never change its address but you can dynamically switch the Droplet it points to at any time.<\/p>\n<p>It\u2019s always a good idea to point your DNS records at Floating IPs instead of specific Droplets. As Floating IPs are free while in use, there\u2019s very little reason not to do so when they give you so much more flexibility during times of failure. Even if you\u2019re not all-in on high availability, Floating IPs can help you manage upgrade windows and server reboots by letting you temporarily redirect traffic to a maintenance page or read-only replica on another Droplet.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/15509\/what-are-floating-ips-in-digitalocean\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What Are Floating IPs In DigitalOcean? \u2013 CloudSavvy IT&#8221; DigitalOcean\u2019s Floating IPs are a way of reserving public IP addresses that are independent of your compute resources. They provide a way to rapidly reroute traffic between your assets without waiting for DNS changes to take effect. Compute components such as Droplets come with their own&#8230;<\/p>\n","protected":false},"author":1,"featured_media":406010,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/83680385.jpeg","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-406009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/406009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=406009"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/406009\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/406010"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=406009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=406009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=406009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}