← Back to Dashboard
Networking

Managing Multiple Public IPs on Ubuntu via CloudStack

Step-by-step walkthrough for mapping Public IPs using Static NAT and Netplan.

1. The Use Case Scenario

This guide handles environments where a Virtual Router (VR) manages the Public IPs, meaning they cannot be assigned directly to the Ubuntu interface. We must map them to internal 10.x.x.x addresses.

2. Phase 1: CloudStack Dashboard Configuration

Step A: Acquire Public IPs

Navigate to Network > Public IP Addresses. Acquire the necessary IPs in your allocated range.

Step B: Secondary Private IPs

Go to Instances > [VM Name] > NICs. Click the primary interface and acquire Secondary IPs (e.g., 10.1.1.225, 10.1.1.227, etc.).

Step C: Enable Static NAT

Under Public IP Addresses, select each IP and map it to its respective internal Secondary IP.

3. Phase 2: Ubuntu OS Configuration (Netplan)

Identify your interface name using ip link show, then modify your configuration.

Open the config: sudo nano /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:  # Replace with ens3/ens18 if needed
      addresses:
        - 10.1.1.225/24
        - 10.1.1.227/24
        - 10.1.1.228/24
        - 10.1.1.229/24
        - 10.1.1.230/24
      routes:
        - to: default
          via: 10.1.1.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]

Apply changes and verify the DNS symlink:

sudo netplan apply
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

4. Phase 3: Verification

Important: Do not ping using the Public IP as the source. Because of NAT, you must bind the test to the internal private IP.

Run this script to verify all IPs are successfully routing through the NAT:

for ip in 10.1.1.225 10.1.1.227 10.1.1.228 10.1.1.229 10.1.1.230; do
  ping -I $ip -c 1 -W 2 8.8.8.8 > /dev/null && echo "IP $ip ONLINE" || echo "IP $ip OFFLINE"
done