Introduction#
If you want your Ubuntu machine to always keep the same IP address, you can set a static IP. This is useful for servers, homelabs, media boxes, and any system you need to reach reliably on your network.
This guide uses Netplan, which is the standard network configuration system on modern Ubuntu releases.
Check Your Current Network Details#
First, identify your network interface name:
ip a
Look for something like ens18, enp0s3, or eth0.
You can also check your current gateway with:
ip route
Make a note of:
- your interface name,
- the IP address you want to use,
- your subnet size (for example
/24), - your gateway address, and
- your DNS servers.
Find Your Netplan Configuration File#
Most Ubuntu systems store Netplan files in /etc/netplan/.
List the files with:
ls /etc/netplan/
You will usually see a file such as:
00-installer-config.yaml
or:
50-cloud-init.yaml
Open the file with a text editor:
sudo nano /etc/netplan/00-installer-config.yaml
If your file has a different name, use that instead.
Set the Static IP#
Replace the existing configuration with something like this:
network:
ethernets:
ens33:
addresses:
- 192.168.1.250/24
dhcp6: true
match:
macaddress: put your device mac address here
nameservers:
addresses:
- 192.168.1.1
search:
- put a domain here if u have one
routes:
- to: default
via: 192.168.1.1
set-name: ens33
version: 2
Change the example values to match your network:
enp0s3→ your actual network interface name,192.168.1.50/24→ the static IP you want to assign,192.168.1.1→ your router or gateway,1.1.1.1and8.8.8.8→ your preferred DNS servers.
Make sure the static IP you choose is not already in use by another device.
Apply the Changes#
Test the configuration first:
sudo netplan try
If everything looks good, apply it permanently:
sudo netplan apply
If you are connected remotely over SSH, be careful when changing network settings because a mistake can disconnect your session.
Verify the Static IP#
Check that the new IP address is active:
ip a
Confirm the default route:
ip route
You can also test connectivity with:
ping -c 4 1.1.1.1
And test DNS resolution with:
ping -c 4 google.co.uk
Conclusion#
Your Ubuntu system should now be using a static IP address. This makes it much easier to manage services such as SSH, Docker, Plex, or any self-hosted applications that need a fixed network address.