Overview
By default a Pod receives its address dynamically. If you need a fixed address inside the guest — for example for a bind-mounted service or a stable private address — you can configure a static IP with Netplan on Ubuntu 18.04 and later. This article shows the process for a private address and notes the rules for public addresses.
Before you begin
- Ubuntu Pod with sudo access.
- The address, subnet prefix, gateway and DNS servers you intend to use. For public IPs these must match the values shown in the ALYPOD Console's Networking tab.
- Console access as a fallback, in case a change breaks your connection.
Steps
- Find your interface name and current configuration:
bash
ip -brief link
ip -brief addr
- Locate the Netplan file (usually
/etc/netplan/50-cloud-init.yamlor00-installer-config.yaml) and back it up:
bash
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak
- Edit the file and set a static address. Keep the existing gateway and nameservers from the current config:
yaml
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses:
- 10.10.0.10/24
routes:
- to: default
via: 10.10.0.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
- Apply with strict permissions and test:
bash
sudo chmod 600 /etc/netplan/*.yaml
sudo netplan try
netplan try rolls back automatically if you do not confirm within 120 seconds — a safe way to avoid losing access.
- If the change is good, make it permanent:
bash
sudo netplan apply
Important
- Never assign a public address that the Console does not show as yours. The gateway will not route it.
- If you change the primary public address, update reverse DNS and any DNS records that point at the old value.
Troubleshooting
- Problem: You lost connectivity after applying. Solution: Use the Console to restore the backup file and run
sudo netplan apply. - Problem: YAML errors. Solution: Check indentation carefully; use spaces, not tabs, and validate with
sudo netplan generate.
Related articles
- [Configuring a static IP on Rocky or AlmaLinux]
- [Understanding IPv4 and IPv6 addresses]
