Setting a Static IP Address on Ubuntu 24.04
Overview
To set a static IP address on Ubuntu 24.04, you will use the Netplan utility. This tool allows you to configure network settings through YAML configuration files.
Steps to Configure Static IP
1. Identify Your Network Interface
Use the following command to list all network interfaces:
ip addr
Note the name of the interface you want to configure (e.g., enp0s3).
2. Locate the Netplan Configuration File.
Check the contents of the /etc/netplan/ directory to find the active configuration file:
ls -la /etc/netplan/
Common files include 50-cloud-init.yaml or similar.
3. Edit the Configuration File
Open the identified YAML file with a text editor (e.g., nano or micro):
sudo micro /etc/netplan/50-cloud-init.yaml
Modify the file to set a static IP. Here’s an example configuration:
network:
version: 2
ethernets:
enp0s3: # Replace with your interface name
dhcp4: false
addresses:
- 192.168.15.185/24 # Your desired static IP
routes:
- to: default
via: 192.168.15.254 # Your gateway
nameservers:
addresses: [8.8.8.8, 8.8.4.4] # DNS servers
4. Apply the Configuration
Save the changes and exit the editor. Then, apply the new configuration with:
sudo netplan apply
5. Verification
To verify that the static IP has been set correctly, use:
ip addr
This process ensures that your Ubuntu server maintains a consistent IP address, which is crucial for server management and network reliability.