One of the most common frustrations for Ubuntu server administrators is dealing with the frequently changing network management tools across distributions and even within a single distribution after updates. This is especially challenging on headless, GUI-less environments where network configuration tasks are done via command line only. The introduction of Netplan on Ubuntu 24LTS, replacing older methods like ifupdown, can confuse many users. Adding complexity is the fact that it’s often difficult to determine which network management platform the installation is using, especially if the system has already been running for some time or updated.
If you’ve already set up your Ubuntu 24LTS server and now need to configure a static IP address for either wired (Ethernet) or wireless (Wi-Fi) devices, this guide will walk you through the steps to ensure a reliable, fixed IP configuration for your server. Whether your system uses Netplan, NetworkManager, or another method, we’ll cover how to set the static IP correctly.
Table of Contents
How to Set a Static IP on Ubuntu 24LTS Server
Step 1: Identify Your Network Interface
To start, we need to identify the network interface for which we want to set a static IP. Whether you’re working with an Ethernet (wired) connection or a Wi-Fi interface, the first step is to determine the correct network interface name.
Use the following command to list all available network interfaces:
ip a
Look for your interface names. Ethernet interfaces are usually named something like enp0s3
or eth0
, while Wi-Fi interfaces are often labeled as wlp2s0
or wifi0
. If you are uncertain, you can also use iwconfig
for more detailed Wi-Fi interface information.
Step 2: Edit Netplan Configuration File
Ubuntu 24LTS uses Netplan as its default tool to manage network configurations. These configurations are stored in YAML files under the /etc/netplan/
directory. In an already running server, you may find configuration files such as 00-installer-config.yaml
or 01-netcfg.yaml
. To begin, open the appropriate configuration file for editing:
sudo nano /etc/netplan/01-netcfg.yaml
Now, modify the configuration to set a static IP address. Below are example configurations for both wired and wireless interfaces:
- For Wired (Ethernet) Device:
network:
version: 2
renderer: networkd
ethernets:
enp0s3: # Replace with your interface name
dhcp4: no
addresses:
- 192.168.1.100/24 # Replace with your desired static IP address
gateway4: 192.168.1.1 # Replace with your gateway (usually your router's IP)
nameservers:
addresses:
- 8.8.8.8 # DNS servers (Google's DNS servers)
- 8.8.4.4
- For Wireless (Wi-Fi) Device:
network:
version: 2
renderer: networkd
wifis:
wlp2s0: # Replace with your Wi-Fi interface name
dhcp4: no
addresses:
- 192.168.1.100/24 # Replace with your desired static IP address
gateway4: 192.168.1.1 # Replace with your gateway IP
nameservers:
addresses:
- 8.8.8.8 # DNS servers
- 8.8.4.4
access-points:
"your-wifi-ssid":
password: "your-wifi-password" # Replace with your Wi-Fi details
Make sure to adjust the following:
enp0s3
orwlp2s0
: The actual name of your network interface.192.168.1.100/24
: Your preferred static IP and subnet mask.192.168.1.1
: Your router’s IP address as the default gateway."your-wifi-ssid"
: Your Wi-Fi network name (SSID)."your-wifi-password"
: Your Wi-Fi password (for wireless connections).8.8.8.8
and8.8.4.4
: DNS servers (you can use others like1.1.1.1
for Cloudflare’s DNS).
Step 3: Apply the Changes
Once you have edited and saved the configuration file, apply the changes using Netplan:
sudo netplan apply
This will apply the static IP configuration to your system. You can verify that the new static IP is set by running:
ip a
This will display all network interfaces and their assigned IP addresses. Ensure that the interface you configured is showing the correct static IP.
Step 4: Verify Connectivity
After applying the changes, you should verify that your network setup is functioning correctly. You can check the routing information to confirm that your default gateway is properly set:
ip route
To test DNS resolution, you can use dig
or nslookup
:
dig google.com
If everything is configured properly, the system should be able to resolve domain names and maintain a stable connection to the network.
Conclusion
Configuring a static IP on your Ubuntu 24LTS server for both wired and wireless devices is crucial for ensuring a stable, persistent network connection. While Ubuntu 24LTS uses Netplan as the default tool for network management, it’s important to understand how to configure the system properly, especially when working in a headless, GUI-less environment. Whether you’re working with a fresh installation or an already set up server, configuring a static IP will ensure consistent network performance.
By following the steps outlined above, you can ensure that your Ubuntu server retains its IP address after reboots, making it suitable for tasks such as hosting, remote access, and networking stability. Whether you’re using Ethernet or Wi-Fi, setting up a static IP on Ubuntu 24LTS is a straightforward process that enhances your server’s reliability.