# Floating IP A **Floating IP** is a public IP address that can quickly move from one server to another. If one server goes down, the Floating IP can switch to a backup server, so your service stays online without interruption. ### Example: Imagine you have two nodes: **Node A** and **Node B**. - You attach the same Floating IP to both. - You set **Node A** as the **master** node with high priority. - **Node B** is the **backup** node with lower priority. By default, the Floating IP points to **Node A**. But if **Node A fails** for any reason, the Floating IP will **automatically switch to Node B**. This happens **without any downtime**. ### Why use it? This setup helps keep your services **always available**, even if one node goes down. It adds **failover support** and improves **network reliability**. ### How to create a Floating IP and attach to Node? 1. Reserve a Floating IP and attach to the node. For more details [click here](./reserve_ip.mdx#use-reserve-ip-as-floating-ip) ### Commands to configure Floating IP Below are the commands to set up a Floating IP on your Ubuntu Node using **Keepalived**. Users can use other tools as well. ```bash #connect to the Node ssh root@ sudo apt update #install keepalived sudo apt install keepalived -y ``` Now create a config file for keepalived ```bash cd /etc/keepalived/ touch keepalived.conf sudo vi keepalived.conf ``` Now for **Master Node** edit the keepalived.conf file to set up the Floating IP. Here is an example configuration: ```bash vrrp_instance VI_1 { state MASTER interface ens3 # Replace with your network interface virtual_router_id 51 priority 100 # Higher priority means this node is preferred authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { } } ``` For **Backup Nodes** , Edit the keepalived.conf file to set up the Floating IP. Here is an example configuration: ```bash vrrp_instance VI_1 { state BACKUP interface ens3 # Replace with your network interface virtual_router_id 51 priority 90 # Lower priority than MASTER authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { } } ``` Now Enable and Start the keepalived ```bash sudo systemctl enable keepalived sudo systemctl start keepalived sudo systemctl status keepalived ``` ### Verify the Floating IP ```bash ip addr show ens3 | grep ``` ---