{"id":2377,"date":"2015-12-04T13:41:57","date_gmt":"2015-12-04T11:41:57","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/configure-floating-ip-centos\/"},"modified":"2015-12-04T13:41:57","modified_gmt":"2015-12-04T11:41:57","slug":"configure-floating-ip-centos","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/configure-floating-ip-centos\/","title":{"rendered":"How to configure Floating IP on CentOS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When you attach a new floating IP, you can find it listed to one of the servers at your UpCloud control panel that the floating IP currently points to. However, using the new floating IP will require some manual setup. Follow the steps below&nbsp;on how to get this done on Ubuntu&nbsp;servers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As an example, we have a cloud server with the public IP address 185.20.139.167, a floating IP 185.20.139.29, with a netmask 255.255.255.255. These are highlighted below in <span style=\"color: #ff0000;\">red<\/span>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before making changes to your network configuration, it\u2019s always a good idea to <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/taking-backups\">take a backup<\/a>. Also, note that if your network configuration becomes inoperable, remember that you can always log in to your cloud server using <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/connecting-to-your-server\">the console connection<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring floating IP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Firstly, you\u2019ll need to configure the servers at the OS level, so start up your cloud server at your\u00a0<a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/\" target=\"_blank\">UpCloud Control Panel<\/a>\u00a0and\u00a0<a rel=\"noopener\" href=\"https:\/\/upcloud.com\/global\/community\/ \/tutorials\/connecting-to-your-server\/\" target=\"_blank\">log in<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check your current network settings with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ip addr<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Commonly the second network interface card (NIC) named <span style=\"color: #ff0000;\"><tt>eth0<\/tt><\/span>,&nbsp;highlighted in red, has your public IPv4 address assigned to it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">2: <span style=\"color: #ff0000;\">eth0<\/span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000\n   link\/ether 6e:d7:1b:bf:3a:5f brd ff:ff:ff:ff:ff:ff\n   inet <span style=\"color: #ff0000;\">185.20.139.167<\/span>\/22 brd 185.20.139.255 scope global eth0\n      valid_lft 53810sec preferred_lft 53810sec<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS hosts, each NIC is controlled by its own configuration file. You will need to&nbsp;create a new network interface configuration file for the floating IP. The easiest way to do this is to&nbsp;duplicate the configuration file of the NIC with your regular IP, this way&nbsp;you don\u2019t need to write the whole file from scratch.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, with <em>eth0<\/em>&nbsp;you can use the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo cp \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \/etc\/sysconfig\/network-scripts\/ifcfg-eth0:1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then edit the new alias interface.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0:1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the same \u201c<em>:1<\/em>\u201d to the <em>device<\/em> name, enter a new parameter <em>NM_CONTROLLED=no<\/em>, replace the IP address with the floating IP and then remove the <em>gateway<\/em> line.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DEVICE=<span style=\"color: #ff0000;\">eth0:1<\/span>\nBOOTPROTO=static\nONBOOT=yes\nNM_CONTROLLED=no\nIPADDR=<span style=\"color: #ff0000;\">185.20.139.29<\/span>\nNETMASK=<span style=\"color: #ff0000;\">255.255.255.255<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file and exit after these changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, restart your network manager to enable the changes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># CentOS 7\nsudo systemctl restart network\n# CentOS 8\nsudo systemctl restart NetworkManager<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you were connected with SSH, the networking restart should not cause you to disconnect. In case you do lose connection and are unable to reconnect, you can always use the web&nbsp;<em>Console<\/em> at th<a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/\" target=\"_blank\">e UpCloud Control Panel<\/a> under your <em>Server settings<\/em> to go through the setup again to make sure everything is entered correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Repeat the process to add the alias on&nbsp;any other&nbsp;servers you wish to use the floating IP on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your configuration is now complete. You can test that it works by transferring the floating IP from one server to another.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, ping the cloud server or attempt to connect to your server through the floating IP via SSH. Alternatively, if you have a web server configured, open the floating IP on your web browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then transfer the floating IP to another cloud server you\u2019ve configured. This can be done either at your <a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/networks\/floating-ips\" target=\"_blank\">UpCloud Control Panel<\/a> or by using the <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/managing-floating-ips-upcloud-api\">UpCloud API<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test the floating IP again with any method you prefer.&nbsp;When you get a connection you have successfully transferred&nbsp;your&nbsp;floating IP.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you get a reply, the floating IP works on that server and you can continue forward. If it didn\u2019t work, make sure you entered the IP address and netmask correctly, and that your firewall isn\u2019t blocking your connections, or try another method&nbsp;to connect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using your new floating IP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can now&nbsp;transfer the floating IP between your cloud&nbsp;servers at your <a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/networks\/floating-ips\" target=\"_blank\">UpCloud Control Panel<\/a> or by using the <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/managing-floating-ips-upcloud-api\">UpCloud API<\/a>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on your intended use case for the floating IP you may wish to continue by setting up automated load balancing, but it\u2019s always possible to manually transfer the traffic between your servers.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","community-category":[259,247],"class_list":["post-2377","tutorial","type-tutorial","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2377"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2377\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2377"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}