Assigning a static IPv6 address to your Ubuntu 22.04 LTS server ensures it is always reachable at the same address — a critical requirement for web servers, mail servers, DNS hosts, and any service that other systems need to connect to reliably. Without a fixed address, dynamic IPv6 assignment can cause disruptions every time your server reboots or your network lease renews. On Ubuntu 22.04, network configuration is handled through Netplan, which uses a clean, human-readable YAML file to define all your network settings in one place.
Why Use a Static IPv6 Address?
By default, most servers receive a dynamically assigned IPv6 address that can change over time. A static IPv6 address eliminates that variability — the address stays fixed regardless of reboots, DHCP lease renewals, or network topology changes. This predictability is essential whenever external systems, DNS records, firewall rules, or end users need to connect to your server at a known, consistent address. It also simplifies security auditing, since you always know exactly which address your server is presenting to the outside world.
What You Need
- Ubuntu 22.04 LTS installed and running.
- IPv6 connectivity active on your network — confirm with your hosting provider or network administrator if you are unsure.
- The following details for your server, obtained from your hosting provider or network administrator: your static IPv6 address, subnet prefix (typically
/64), default IPv6 gateway, and DNS server addresses.
- Root or sudo access to the server.
Step 1: Identify Your Network Interface Name
Open a terminal and run the following command to list all network interfaces currently active on the system:
ip a
Scan the output for your primary network interface. Common names include ens33, eth0, and enp0s3, but the exact name depends on your hardware and virtualization platform. Make a note of it — you will need it in Step 3 when editing the Netplan configuration file.
Step 2: Back Up Your Netplan Configuration
Before making any changes to your network configuration, create a backup of the existing Netplan file. This gives you a quick and reliable way to restore your previous working state if something goes wrong during editing:
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak
If your system uses a differently named Netplan file, list all files in the directory first with ls /etc/netplan/ and back up whichever .yaml file is present. On some Ubuntu 22.04 installations — particularly cloud images — the file may be named 50-cloud-init.yaml instead.
Step 3: Edit the Netplan Configuration File
Open the Netplan configuration file in a text editor:
sudo nano /etc/netplan/00-installer-config.yaml
Add or update the IPv6 section to match the example below. Replace ens33 with your actual interface name, and substitute all placeholder address values with the real details provided by your hosting provider or network administrator:
network:
version: 2
ethernets:
ens33:
dhcp6: no
addresses:
- 2001:db8::1001/64
gateway6: 2001:db8::1
nameservers:
addresses:
- 2001:4860:4860::8888
- 2001:4860:4860::8844
The DNS addresses shown above (2001:4860:4860::8888 and 2001:4860:4860::8844) are Google’s public IPv6 DNS resolvers. You can use these as-is if your provider does not specify dedicated DNS servers, or substitute Cloudflare’s IPv6 resolvers (2606:4700:4700::1111 and 2606:4700:4700::1001) as an alternative.
Important: YAML is whitespace-sensitive — indentation must use spaces, never tabs, and the structure must match exactly. A single misplaced space can cause Netplan to reject the entire file. Save the file with Ctrl+O, press Enter to confirm the filename, then exit with Ctrl+X.
Step 4: Test and Apply the Configuration
Before applying the change permanently, use netplan try to test it safely. This command applies the new configuration temporarily and automatically reverts it after 120 seconds unless you explicitly confirm — giving you a safety window to verify that your connection is still working before committing:
sudo netplan try
If the configuration is accepted and your connection remains stable, confirm the change by pressing Enter when prompted. If you lose connectivity and cannot confirm in time, Netplan will automatically roll back to the previous configuration after the timeout expires — protecting you from being permanently locked out.
Once confirmed, apply the configuration permanently with:
sudo netplan apply
Step 5: Verify the Address and Test Connectivity
Confirm that your static IPv6 address has been successfully assigned to the interface:
ip -6 addr show
Your static address should appear in the output next to your interface name. Next, test that outbound IPv6 connectivity is functioning correctly:
ping6 google.com
A successful ping response confirms that your server can reach IPv6 destinations and that DNS resolution over IPv6 is working as expected. If the ping fails, double-check your gateway and DNS entries in the Netplan file, verify that your hosting provider has IPv6 enabled on your connection, and ensure the correct prefix length is set for your address.
Tips for Success
- Always back up before making changes. The backup created in Step 2 lets you restore your working configuration instantly if something goes wrong — a step that takes seconds but can save hours of troubleshooting.
- Record your network settings somewhere safe. Keep a note of your static IPv6 address, prefix length, gateway, and DNS values outside of the server itself — in a password manager, infrastructure documentation system, or secure note. If the server becomes unreachable, you will need these details to troubleshoot from outside.
- Ensure you have console or out-of-band access. If a misconfigured network file cuts off SSH access, a console connection (available through your hosting provider’s control panel or a physical terminal) allows you to log in and fix the issue without relying on network connectivity. Many cloud providers offer browser-based console access for exactly this scenario.
- Validate your YAML syntax before applying. You can check your Netplan file for syntax errors without applying any changes by running
sudo netplan generate. Any YAML formatting issues will be reported immediately, before they affect your live network configuration.
Your Ubuntu 22.04 LTS server now has a permanent, static IPv6 address configured and managed through Netplan. Going forward, the address will remain consistent across reboots and network changes, giving you a stable, reliable foundation for any service — from web hosting to email delivery — that depends on a fixed, publicly reachable IPv6 address.