How to Set Up a Static IP Address on an Ubuntu Server

Setting up a static IP address is essential for maintaining consistent network connectivity, especially for servers. In Ubuntu, this can be achieved using the Netplan utility. In this tutorial, I’ll guide you through setting up a static IP address for your Ubuntu server.

An Ubuntu server.
Root or sudo access to the server.
Knowledge of your network’s gateway and preferred DNS addresses.
Step-by-Step Guide:

1. Login to your server:
First, ensure you’re connected to your server, either directly or via SSH.

2. Locate the netplan configuration:
Ubuntu’s netplan configuration files are stored in the /etc/netplan/ directory. Navigate to this directory and check the available configurations:

ls /etc/netplan/

For the sake of this guide, our configuration file is named 00-installer-config.yaml. Your filename might differ, so ensure to use the correct name in the following steps.

3. Edit the Configuration: Open the configuration file in a text editor of your choice, like nano:

sudo nano /etc/netplan/00-installer-config.yaml

4. Enter the Static IP Configuration: Replace or modify the contents with the following template, making sure to adjust the interface name, gateway, and other parameters to fit your network setup:

version: 2
dhcp4: no
addresses: []
– to:
addresses: [,]


  • enp0s3 should be replaced with your server’s interface name (use ip a or ifconfig to find this).
  • Adjust the /24 subnet mask if your network configuration is different.
  • Use the appropriate gateway and DNS addresses for your network setup.

5. Apply Your Changes: After saving and closing the file, apply the new configuration with:

sudo netplan apply

6. Confirm the Configuration: Finally, verify that your static IP has been applied:

ip a

Your server should now proudly display the static IP address

Conclusion: Setting a static IP address on your Ubuntu server ensures reliable connectivity and reduces potential network issues. Make sure that this IP is either reserved or excluded from your network’s DHCP range to avoid any conflicts. Happy networking!

Leave a Reply

Your email address will not be published. Required fields are marked *