Understanding Floating IPs vs. Virtual IPs: Key Differences and Use Cases in Modern Networking


3 views

While both Floating IPs and Virtual IPs (VIPs) serve as abstraction layers in networking, they operate with distinct mechanisms:

  • Floating IP: A publicly routable IP address that can be dynamically reassigned between instances or nodes, typically used in cloud environments for high availability.
  • Virtual IP: An IP address not tied to specific hardware, used to represent multiple servers as a single entity, commonly seen in load balancing scenarios.

Here's a Python example demonstrating how cloud providers might handle Floating IP assignment:


import openstack

conn = openstack.connect(cloud='mycloud')
server = conn.compute.find_server('web-server-01')
floating_ip = conn.network.find_ip('198.51.100.42')

conn.compute.add_floating_ip_to_server(server, floating_ip.ip)

For VIP implementation, consider this HAProxy configuration snippet:


frontend web_frontend
    bind 192.0.2.100:80
    default_backend web_servers

backend web_servers
    server webserver1 192.0.2.101:80 check
    server webserver2 192.0.2.102:80 check
Scenario Floating IP Solution Virtual IP Solution
Cloud instance failover Primary choice Not typically used
Load balancing Rarely used Standard approach
Database clustering Common for master promotion Used with connection pooling

Floating IPs often rely on:

  • ARP updates (in traditional networks)
  • API calls (in cloud environments)

Virtual IPs typically use:

  • TCP connection proxying
  • DNS round-robin techniques
  • BGP advertisements (in global load balancing)

The failover time differs significantly:

  • Floating IP reassignment: Typically 1-30 seconds depending on cloud provider
  • VIP failover: Often sub-second when using protocols like VRRP

Here's a VRRP configuration example showing VIP setup:


vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    virtual_ipaddress {
        192.0.2.100/24
    }
}

While both Floating IPs and Virtual IPs (VIPs) represent abstraction layers in networking, they serve fundamentally different purposes:

# Floating IP Example (OpenStack API)
import openstack

conn = openstack.connect(cloud='mycloud')
server = conn.compute.find_server("web-server-1")
floating_ip = conn.network.find_available_ip()
conn.compute.add_floating_ip_to_server(server, floating_ip.floating_ip_address)

VIPs typically operate at these layers:

  • Layer 4 (Transport): TCP/UDP port forwarding
  • Layer 7 (Application): HTTP/HTTPS content-based routing
# HAProxy VIP configuration example
frontend http-in
    bind 192.168.1.100:80
    default_backend servers

backend servers
    server server1 10.0.0.1:80 check
    server server2 10.0.0.2:80 check
Scenario Floating IP Virtual IP
Cloud instance failover ✔ Primary use case ✖ Not typical
Load balancing ✖ Rarely used ✔ Standard approach
DRBD cluster ✔ Common in Pacemaker ✔ Alternative method

The technical implementations reveal key differences:

# AWS EC2 Floating IP association (AWS CLI)
aws ec2 associate-address \
    --instance-id i-0b263919b7621e117 \
    --public-ip 203.0.113.7

# Keepalived VIP configuration (VRRP)
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    virtual_ipaddress {
        192.168.1.100/24
    }
}

Choose Floating IP when:

  • Implementing active-passive failover in cloud environments
  • Needing to reassign public IPs without DNS changes
  • Working with stateful services that can't be load balanced

Opt for Virtual IP when:

  • Building highly available services with multiple active nodes
  • Implementing load balancing at network layers 4-7
  • Requiring transparent failover for clients