Ubuntu Server 24.
04 – Static IP Setup (CLI)
1. Check Interface Name:
Run the following command to check the name of your network interface:
ip a
2. Edit Netplan Config:
Open the Netplan configuration file (usually 00-installer-config.yaml):
sudo nano /etc/netplan/00-installer-config.yaml
3. Use this Configuration Format:
network:
version: 2
ethernets:
enp0s3: # Change this to your interface name
dhcp4: false
addresses:
- 192.168.1.100/24 # Your static IP & subnet
gateway4: 192.168.1.1 # Your default gateway
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
4. Apply the Configuration:
Save the file and apply the settings using:
sudo netplan apply
5. Verify the Configuration:
Check if the IP and routes are correctly set:
ip a
ip route
✅ Done! Your Ubuntu server now uses a static IP.