Skip to main content

Floating IPs

Floating IPs provide static, reassignable IP addresses that can be moved between VPS instances for high availability and failover scenarios.

Overviewโ€‹

Floating IPs offer:

  • Static IP Addresses: Never change, even when reassigned
  • High Availability: Quick failover between instances
  • Load Balancing: Distribute traffic across multiple servers
  • Disaster Recovery: Instant IP reassignment during outages

Creating Floating IPsโ€‹

Via Dashboardโ€‹

  1. Navigate to Networking > Floating IPs
  2. Click Reserve Floating IP
  3. Select region and assign to instance
  4. Configure reverse DNS (optional)

Via CLIโ€‹

# Reserve a floating IP
lineserve network reserve-floating-ip \
--region us-east-1 \
--name "web-server-ip"

# Assign to instance
lineserve network assign-floating-ip \
--ip 203.0.113.10 \
--instance-id vps-12345678

# List floating IPs
lineserve network list-floating-ips

Configurationโ€‹

Assign Floating IPโ€‹

# Assign to VPS instance
lineserve network assign-floating-ip \
--ip 203.0.113.10 \
--instance-id vps-12345678

# Unassign floating IP
lineserve network unassign-floating-ip \
--ip 203.0.113.10

Network Interface Setupโ€‹

# Configure on Ubuntu/Debian
cat >> /etc/netplan/01-netcfg.yaml << EOF
network:
version: 2
ethernets:
eth0:
addresses:
- 203.0.113.10/32
routes:
- to: 0.0.0.0/0
via: 10.0.0.1
metric: 100
EOF

netplan apply

High Availability Setupโ€‹

Automatic Failover Scriptโ€‹

#!/bin/bash
# failover.sh - Automatic floating IP failover

PRIMARY_INSTANCE="vps-12345678"
BACKUP_INSTANCE="vps-87654321"
FLOATING_IP="203.0.113.10"

# Check primary server health
if ! ping -c 3 $PRIMARY_INSTANCE > /dev/null; then
echo "Primary server down, failing over..."

# Reassign floating IP to backup
lineserve network assign-floating-ip \
--ip $FLOATING_IP \
--instance-id $BACKUP_INSTANCE

echo "Failover completed"
fi

Load Balancer Integrationโ€‹

# Configure HAProxy with floating IP
cat > /etc/haproxy/haproxy.cfg << EOF
global
daemon

defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

frontend web_frontend
bind 203.0.113.10:80
default_backend web_servers

backend web_servers
balance roundrobin
server web1 10.0.1.10:80 check
server web2 10.0.1.11:80 check
EOF

Use Casesโ€‹

Web Server Failoverโ€‹

  • Primary web server with floating IP
  • Backup server ready for instant takeover
  • DNS points to floating IP for zero downtime

Database Clusteringโ€‹

  • Master database with floating IP
  • Slave promotion with IP reassignment
  • Application connections remain stable

API Gatewayโ€‹

  • Multiple API servers behind floating IP
  • Load balancing and health checks
  • Seamless server maintenance

Pricingโ€‹

RegionPrice per IP/month
US East$3.00
US West$3.00
Europe$3.50
Asia Pacific$4.00

Additional Costs:

  • Bandwidth: Standard rates apply
  • No charge for IP reassignment

Best Practicesโ€‹

Securityโ€‹

  • Configure firewall rules for floating IPs
  • Use security groups for access control
  • Monitor traffic and access logs

Monitoringโ€‹

# Monitor floating IP status
lineserve network get-floating-ip --ip 203.0.113.10

# Set up health checks
lineserve monitoring create-check \
--type http \
--url http://203.0.113.10/health \
--interval 30s

Automationโ€‹

# Python script for automated failover
import requests
import time

def check_server_health(ip):
try:
response = requests.get(f"http://{ip}/health", timeout=5)
return response.status_code == 200
except:
return False

def failover_floating_ip(floating_ip, backup_instance):
# Lineserve API call to reassign IP
pass

# Health check loop
while True:
if not check_server_health("203.0.113.10"):
failover_floating_ip("203.0.113.10", "vps-backup")
time.sleep(30)

Troubleshootingโ€‹

Common Issuesโ€‹

IP Not Responding

  • Check instance network configuration
  • Verify floating IP assignment
  • Review firewall rules

Slow Failover

  • Optimize health check intervals
  • Use API for faster reassignment
  • Pre-configure backup instances

Network Conflicts

  • Ensure unique IP assignments
  • Check routing table conflicts
  • Verify subnet configurations

API Referenceโ€‹

Reserve Floating IPโ€‹

POST /v1/network/floating-ips
{
"region": "us-east-1",
"name": "web-server-ip"
}

Assign Floating IPโ€‹

PUT /v1/network/floating-ips/{ip}/assign
{
"instance_id": "vps-12345678"
}

List Floating IPsโ€‹

GET /v1/network/floating-ips

Next Stepsโ€‹