News about our company, tutorials about IT and much more you will find in this page.
There are different ways to configure a Static IPv4 Address in Ubuntu 24. Whether you prefer using Netplan (the default tool), systemd-networkd, or the legacy interfaces method, this guide will walk you through each approach step-by-step.
Netplan is the default network configuration tool in Ubuntu 24. Follow these steps to configure a static IPv4 address:
Open a terminal and type:
ip a
Look for your network interface name (e.g., eth0
, enp0s3
, etc.).
Check which network is up:
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
Netplan configuration files are located in /etc/netplan/
. Open the file (e.g., 01-netcfg.yaml
):
sudo nano /etc/netplan/01-netcfg.yaml
Replace the existing configuration with the following, customizing it for your network:
Example:
network:
version: 2
ethernets:
eno1np0: # Replace with your network interface name
addresses:
- 192.168.10.5/24 # Replace with your static IP and subnet mask
nameservers:
addresses: [1.1.1.1,8.8.8.8] # Replace with DNS server IPs
routes:
- to: default
via: 192.168.1.1 # Replace with your gateway IP
Save and apply the configuration:
sudo netplan apply
Check the new IP configuration:
ip a
Test connectivity:
ping google.com
For those who prefer not to use Netplan, you can configure the network using systemd-networkd
.
If Netplan is enabled, disable it:
sudo mv /etc/netplan /etc/netplan.bak
sudo systemctl disable systemd-networkd-wait-online
Create a configuration file in /etc/systemd/network/
:
sudo nano /etc/systemd/network/10-static.network
Add the following content:
[Match]
Name=<interface_name> # Replace with your network interface name
[Network]
Address=<static_IP>/<prefix> # Replace with your static IP and subnet mask
Gateway=<gateway_IP> # Replace with your gateway IP
DNS=<dns_server_1> <dns_server_2> # Replace with DNS servers
Example:
[Match]
Name=enp0s3
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8 8.8.4.4
Enable and restart the service:
sudo systemctl enable systemd-networkd
sudo systemctl restart systemd-networkd
Go to systemd directory open resolved.conf
sudo nano /etc/resolv.conf
Then add DNS to the file
[Resolved]
DNS=8.8.8.8 1.1.1.1
Check the network interface:
ip a
Test connectivity:
ping google.com
For users familiar with older methods, you can use the ifupdown
package.
If not already installed:
sudo apt update
sudo apt install ifupdown
Edit the /etc/network/interfaces
file:
sudo nano /etc/network/interfaces
Add the following:
Example:
auto enp0s3 # Replace with your network interface name
iface enp0s3 inet static
address 192.168.1.100 # Replace with your static IP
netmask 255.255.255.0 # Replace with your subnet mask
gateway 192.168.1.1 # Replace with your gateway
dns-nameservers 8.8.8.8 8.8.4.4 # Replace with DNS servers
Apply the changes:
sudo systemctl restart systemd-networkd
Check the IP configuration:
ip a
Test connectivity:
ping google.com
This tutorial covered three different ways to configure a static IPv4 address on Ubuntu 24. While Netplan is the default, both systemd-networkd
and the legacy /etc/network/interfaces
method provide alternatives for different use cases. Choose the approach that best fits your environment and preferences.
If you encounter any issues or have questions, feel free to ask for help using our method of contact.
If you are interested in Configuring a Static IPv4 Address in AlmaLinux 9.