To configure a static IP address on Ubuntu Server 24.04, you’ll need to modify the Netplan configuration file. Here’s how to do it:
- First, identify your network interface name:
ip a
- Create or edit the Netplan configuration file: (there might be a different file name too, like 50-cloud-init.yaml) or whatever is avaialble, i will be using below
sudo nano /etc/netplan/00-installer-config.yaml
- Configure the file with your static IP information:
network:
version: 2
renderer: networkd
ethernets:
enp0s18: # Replace with your interface name
dhcp4: false
addresses:
- 10.11.12.7/24 # Your desired static IP/subnet mask
routes:
- to: default
via: 10.11.12.1 # Your gateway IP
nameservers:
addresses: [10.11.12.1, 1.1.1.1] # DNS servers
- Apply the configuration:
sudo netplan apply
- Verify the new IP address:
ip a
Make sure to replace:
enp0s18 with your actual interface name10.11.12.7/24with your desired IP address and subnet mask10.11.12.1with your gateway address- DNS servers as needed for your network
If you encounter any issues, you can check the configuration with:
sudo netplan --debug apply