Title: How to Add Floating IP to Ubuntu and Debian Servers with Netplan
Author: Immanuel Raj
Published: August 14, 2025
Last modified: August 15, 2025

---

![A tech-themed image with a dark background. A glowing orange Ubuntu logo on the
left is connected to a glowing blue globe (representing the internet) on the right
by a line with the word 'Netplan' in the center.](https://cdn.immanuelraj.dev/immanuelraj.
dev/wordpress/images/Featured-Images/FI-netplan-floating-ip-configuration.png)

# How to Add Floating IP to Ubuntu and Debian Servers with Netplan

[August 14, 2025](https://immanuelraj.dev/netplan-floating-ip-configuration/)

—

by

[Immanuel Raj](https://immanuelraj.dev/author/iamimmanuelraj/)

in [Linux](https://immanuelraj.dev/category/linux/), [Networking](https://immanuelraj.dev/category/networking/),
[Self Hosting](https://immanuelraj.dev/category/self-hosting/)

Read Time

8–11 minutes

Floating IP addresses provide high availability and seamless failover capabilities
for Linux servers. This comprehensive guide demonstrates how to configure floating
IPs on Ubuntu and Debian systems using Netplan, enabling automatic IP migration 
between servers for improved reliability and redundancy.

## Prerequisites for Floating IP Configuration

Before configuring floating IPs on your Ubuntu or Debian server, ensure you have
the following requirements for successful implementation:

 * **Ubuntu 18.04+ or Debian 9+:** Modern distributions with Netplan support
 * **Root or Sudo Access:** Administrative privileges for network configuration
 * **Available Floating IP:** A secondary IP address allocated by your hosting provider
 * **Network Interface Access:** Understanding of your server’s network interface
   names
 * **Backup Configuration:** Always backup existing network configs before changes

#### ⚠️ Important Network Safety Notice

**Always backup your network configuration before making changes.** Incorrect network
settings can disconnect you from your server, requiring console access to fix.

**Best Practice:** Test configurations in a development environment first, and ensure
you have console access to your server before applying network changes.

## Understanding Floating IPs and Netplan

Floating IPs are virtual IP addresses that can be moved between servers without 
changing DNS records or requiring manual reconfiguration. Netplan is Ubuntu’s network
configuration tool that uses YAML files to define network settings.

### What Are Floating IPs?

 * **High Availability:** Enable automatic failover between servers
 * **Load Balancing:** Distribute traffic across multiple instances
 * **Zero Downtime:** Switch services without DNS propagation delays
 * **Disaster Recovery:** Quick recovery from server failures

### Netplan Configuration Benefits

 * **Declarative Configuration:** YAML-based, human-readable format
 * **Backend Agnostic:** Works with NetworkManager and systemd-networkd
 * **Validation:** Built-in configuration validation before applying
 * **Consistent:** Standardized across Ubuntu distributions

## Step-by-Step Floating IP Configuration

Follow this comprehensive guide to configure floating IPs using Netplan on Ubuntu
and Debian systems. Each step includes validation commands to ensure proper setup.

### Step 1: Identify Your Network Interface

First, identify your primary network interface name and current IP configuration.

    ```wp-block-code
    # List all network interfaces
    ip addr show

    # Check current network configuration
    ip route show

    # View existing Netplan configuration
    ls -la /etc/netplan/
    cat /etc/netplan/*.yaml
    ```

### Step 2: Create Floating IP Netplan Configuration

Create a new Netplan configuration file specifically for your floating IP address.
This keeps the configuration organized and easily manageable.

    ```wp-block-code
    # Create a new Netplan configuration file
    sudo nano /etc/netplan/01-floating.yaml
    ```

Add the following configuration to the file:

    ```wp-block-code
    network:
      version: 2
      ethernets:
        eth0:  # Replace with your actual interface name
          dhcp4: true  # Keep main IP from DHCP
          addresses:
            - 10.0.0.8/32  # Your floating IP address
          routes:
            - to: 10.0.0.8/32
              via: 0.0.0.0
              scope: link
    ```

#### 💡 Netplan Configuration Best Practices

**Important configuration notes:**

 * **Interface Names:** Use `ip addr` to find your actual interface name (eth0, 
   ens3, etc.)
 * **CIDR Notation:** Use /32 for single floating IP addresses
 * **DHCP Preservation:** Keep dhcp4: true to maintain your primary IP
 * **File Naming:** Use numeric prefixes (01-, 02-) to control application order

### Step 3: Validate and Apply Netplan Configuration

Before applying the configuration, validate it to prevent network connectivity issues.

    ```wp-block-code
    # Test the Netplan configuration
    sudo netplan try

    # If validation passes, apply the configuration
    sudo netplan apply

    # Verify the floating IP is configured
    ip addr show eth0
    ip route show
    ```

### Step 4: Manual IP Configuration Method (Alternative)

For temporary or testing purposes, you can also configure floating IPs manually 
using ip commands.

    ```wp-block-code
    # Add floating IP to interface
    sudo ip addr add 5.161.24.41/32 dev eth0

    # Add route for the floating IP
    sudo ip route add 5.161.24.41/32 dev eth0

    # Verify configuration
    ip addr show eth0
    ip route show | grep 5.161.24.41
    ```

#### ⚠️ Manual Configuration Limitations

**Manual configurations are not persistent.** They will be lost after a system reboot.
Use Netplan for permanent configuration.

**Use Cases:** Manual configuration is useful for testing, temporary setups, or 
emergency situations.

### Step 5: Enable IP Forwarding (Optional)

If your server acts as a router or gateway, enable IP forwarding to allow traffic
routing between interfaces.

    ```wp-block-code
    # Enable IP forwarding temporarily
    sudo sysctl net.ipv4.ip_forward=1

    # Make IP forwarding permanent
    echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf

    # Apply sysctl changes
    sudo sysctl -p

    # Verify IP forwarding is enabled
    cat /proc/sys/net/ipv4/ip_forward
    ```

## Advanced Floating IP Configuration

Learn advanced techniques for managing multiple floating IPs and complex network
setups.

### Multiple Floating IPs Configuration

Configure multiple floating IP addresses on a single interface for high-availability
setups.

    ```wp-block-code
    # Advanced Netplan configuration with multiple floating IPs
    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: true
          addresses:
            - 10.0.0.8/32    # First floating IP
            - 10.0.0.9/32    # Second floating IP
            - 10.0.0.10/32   # Third floating IP
          routes:
            - to: 10.0.0.8/32
              via: 0.0.0.0
              scope: link
            - to: 10.0.0.9/32
              via: 0.0.0.0
              scope: link
            - to: 10.0.0.10/32
              via: 0.0.0.0
              scope: link
    ```

### VLAN-Based Floating IP Configuration

Configure floating IPs on VLAN interfaces for network segmentation.

    ```wp-block-code
    # VLAN configuration with floating IP
    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: true
      vlans:
        eth0.100:
          id: 100
          link: eth0
          addresses:
            - 192.168.100.10/24
            - 192.168.100.50/32  # Floating IP on VLAN
    ```

### Floating IP with Static Routes

Add custom routing rules for floating IP traffic management.

    ```wp-block-code
    # Advanced routing configuration
    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: true
          addresses:
            - 10.0.0.8/32
          routes:
            - to: 10.0.0.8/32
              via: 0.0.0.0
              scope: link
            - to: 10.0.0.0/24
              via: 10.0.0.1
              metric: 100
    ```

## Troubleshooting Floating IP Issues

Comprehensive solutions for common problems encountered when configuring floating
IPs.

### Common Issues and Solutions

 * **Netplan Apply Fails:** Check YAML syntax and indentation
 * **IP Not Accessible:** Verify routing and firewall rules
 * **Configuration Lost After Reboot:** Ensure Netplan files are properly saved
 * **Interface Not Found:** Confirm correct interface name with `ip addr`
 * **DHCP Conflicts:** Check for IP address conflicts with DHCP range

### Diagnostic Commands

    ```wp-block-code
    # Check Netplan configuration syntax
    sudo netplan --debug try

    # View detailed network information
    ip addr show
    ip route show table all

    # Test connectivity to floating IP
    ping -I eth0 10.0.0.8

    # Check ARP table
    arp -a

    # Monitor network traffic
    sudo tcpdump -i eth0 host 10.0.0.8

    # Check systemd-networkd status
    sudo systemctl status systemd-networkd

    # View network logs
    journalctl -u systemd-networkd
    ```

### Emergency Recovery Procedures

If network configuration causes connectivity issues, use these recovery methods:

    ```wp-block-code
    # Reset to DHCP-only configuration
    sudo rm /etc/netplan/01-floating.yaml
    sudo netplan apply

    # Manually restore network connectivity
    sudo dhclient eth0

    # Restart networking services
    sudo systemctl restart systemd-networkd
    sudo systemctl restart systemd-resolved

    # Emergency network reset
    sudo ip addr flush dev eth0
    sudo dhclient eth0
    ```

## Monitoring and Automation

Implement monitoring and automation for floating IP management in production environments.

### Floating IP Health Check Script

    ```wp-block-code
    #!/bin/bash
    # floating-ip-monitor.sh

    FLOATING_IP="10.0.0.8"
    INTERFACE="eth0"
    LOG_FILE="/var/log/floating-ip-monitor.log"

    # Function to log messages
    log_message() {
        echo "$(date): $1" >> "$LOG_FILE"
    }

    # Check if floating IP is configured
    if ip addr show "$INTERFACE" | grep -q "$FLOATING_IP"; then
        log_message "Floating IP $FLOATING_IP is configured on $INTERFACE"

        # Test connectivity
        if ping -c 1 -W 5 "$FLOATING_IP" > /dev/null 2>&1; then
            log_message "Floating IP $FLOATING_IP is reachable"
            exit 0
        else
            log_message "WARNING: Floating IP $FLOATING_IP is not reachable"
            exit 1
        fi
    else
        log_message "ERROR: Floating IP $FLOATING_IP is not configured"
        exit 2
    fi
    ```

### Automated Floating IP Assignment

    ```wp-block-code
    #!/bin/bash
    # assign-floating-ip.sh

    FLOATING_IP="10.0.0.8"
    INTERFACE="eth0"

    # Check if IP is already assigned
    if ! ip addr show "$INTERFACE" | grep -q "$FLOATING_IP"; then
        echo "Assigning floating IP $FLOATING_IP to $INTERFACE"

        # Add IP address
        sudo ip addr add "$FLOATING_IP/32" dev "$INTERFACE"

        # Add route
        sudo ip route add "$FLOATING_IP/32" dev "$INTERFACE"

        # Verify assignment
        if ip addr show "$INTERFACE" | grep -q "$FLOATING_IP"; then
            echo "Successfully assigned floating IP $FLOATING_IP"
        else
            echo "Failed to assign floating IP $FLOATING_IP"
            exit 1
        fi
    else
        echo "Floating IP $FLOATING_IP is already assigned"
    fi
    ```

## Security Considerations

Implement security best practices when configuring floating IPs to protect your 
infrastructure.

#### 🔒 Security Best Practices

**Essential security measures:**

 * **Firewall Rules:** Configure iptables or ufw to control floating IP access
 * **Access Control:** Limit floating IP usage to authorized services only
 * **Monitoring:** Log all floating IP assignment and usage activities
 * **Network Segmentation:** Use VLANs to isolate floating IP traffic
 * **Regular Audits:** Review floating IP configurations and access logs

### Firewall Configuration for Floating IPs

    ```wp-block-code
    # UFW firewall rules for floating IP
    sudo ufw allow in on eth0 to 10.0.0.8 port 80
    sudo ufw allow in on eth0 to 10.0.0.8 port 443
    sudo ufw allow in on eth0 to 10.0.0.8 port 22

    # iptables rules for floating IP
    sudo iptables -A INPUT -d 10.0.0.8 -p tcp --dport 80 -j ACCEPT
    sudo iptables -A INPUT -d 10.0.0.8 -p tcp --dport 443 -j ACCEPT
    sudo iptables -A INPUT -d 10.0.0.8 -p tcp --dport 22 -j ACCEPT

    # Save iptables rules
    sudo iptables-save > /etc/iptables/rules.v4
    ```

## Additional Resources for Network Management

 * [Official Netplan Documentation](https://netplan.io/reference) – Comprehensive
   Netplan configuration reference
 * [Ubuntu Network Configuration Guide](https://ubuntu.com/server/docs/network-configuration)–
   Ubuntu-specific networking documentation
 * [Debian Network Configuration](https://www.debian.org/doc/manuals/debian-reference/ch05.en.html)–
   Debian networking setup and management
 * [Linux IP Command Manual](https://man7.org/linux/man-pages/man8/ip.8.html) – 
   Complete reference for the ip command

## Conclusion: Mastering Floating IP Configuration

Floating IP configuration using Netplan provides a robust foundation for high-availability
infrastructure on Ubuntu and Debian systems. By understanding both persistent Netplan
configurations and manual IP management techniques, you can implement reliable network
failover solutions.

The combination of Netplan’s declarative configuration model and manual IP commands
gives you flexibility for both permanent infrastructure and temporary testing scenarios.
Whether you’re implementing load balancing, disaster recovery, or simple service
migration, floating IPs provide the network agility needed for modern server management.

#### 🚀 Implementation Checklist

**Complete these steps for successful floating IP deployment:**

 * ✅ Backup existing network configuration
 * ✅ Create Netplan floating IP configuration
 * ✅ Test configuration with netplan try
 * ✅ Apply configuration and verify connectivity
 * ✅ Configure firewall rules for floating IP
 * ✅ Implement monitoring and health checks
 * ✅ Document configuration for team reference

Ready to implement floating IPs in your infrastructure? Start with a test environment
to familiarize yourself with Netplan configuration, then gradually deploy to production
systems with proper monitoring and backup procedures in place.

[linux](https://immanuelraj.dev/tags/linux/) [networking](https://immanuelraj.dev/tags/networking/)
[security](https://immanuelraj.dev/tags/security/) [ubuntu](https://immanuelraj.dev/tags/ubuntu/)

[Previous:  Complete Frappe Security Guide: Block Administrator Installation & Configuration](https://immanuelraj.dev/secure-frappe-admin-block-administrator-guide/)

[Next:  Object Cache | Page Cache | OP Cache – Caching for WordPress](https://immanuelraj.dev/wordpress-caching-opcache-object-page-optimization/)

![Immanuel Raj Avatar](https://secure.gravatar.com/avatar/88db6e1fa27cf854075acbaa156189ace30cf3701b2d8640cd774280ead1d4d3?
s=80&d=mm&r=g)

## About the author

Software Developer & Technology Consultant

---

## Popular Categories

 * [Bible](https://immanuelraj.dev/category/bible/) (1)
 * [Cloudflare](https://immanuelraj.dev/category/cloudflare/) (1)
 * [Databases](https://immanuelraj.dev/category/databases/) (1)
 * [Docker](https://immanuelraj.dev/category/docker/) (1)
 * [Email](https://immanuelraj.dev/category/email/) (1)
 * [ERPNext](https://immanuelraj.dev/category/erpnext/) (3)
 * [Frappe](https://immanuelraj.dev/category/frappe/) (2)
 * [Github Actins](https://immanuelraj.dev/category/github-actins/) (1)
 * [God](https://immanuelraj.dev/category/god/) (1)
 * [Google Cloud](https://immanuelraj.dev/category/gcp/) (1)
 * [Hosting](https://immanuelraj.dev/category/hosting/) (2)
 * [Life](https://immanuelraj.dev/category/life/) (1)
 * [Linux](https://immanuelraj.dev/category/linux/) (13)
 * [ML](https://immanuelraj.dev/category/ml/) (1)
 * [Networking](https://immanuelraj.dev/category/networking/) (2)
 * [Security](https://immanuelraj.dev/category/security/) (2)
 * [Self Hosting](https://immanuelraj.dev/category/self-hosting/) (7)
 * [SSL](https://immanuelraj.dev/category/ssl/) (3)
 * [Terminal](https://immanuelraj.dev/category/terminal/) (1)
 * [Tools](https://immanuelraj.dev/category/tools/) (2)
 * [Uncategorized](https://immanuelraj.dev/category/uncategorized/) (8)
 * [Web](https://immanuelraj.dev/category/web/) (2)
 * [WordPress](https://immanuelraj.dev/category/wordpress/) (1)

---

## Useful Links

Links I found useful and wanted to share.

 * [Sponsor Me](https://github.com/sponsors/iamimmanuelraj)

---

## Search the website

Search