How To Set Static IP on Ubuntu

Set Static IP on Ubuntu

In today’s interconnected world, having a stable and reliable network connection is essential. Ubuntu, a popular Linux distribution, offers users the flexibility to set a static IP address, providing improved network stability and easier access to services. In this comprehensive guide, we will walk you through the process of setting a static IP on Ubuntu, accompanied by detailed step-by-step instructions and a command line example. So, let’s dive in and empower you to take control of your network configuration.

Understanding Static IP and Its Advantages

Before we begin, let’s clarify what a static IP address is and explore its advantages over a dynamic IP. A static IP address is a manually assigned address that remains constant, allowing devices on a network to maintain a fixed identity. In contrast, a dynamic IP address is automatically assigned by a DHCP server, and it may change over time.

The advantages of using a static IP address are numerous. Firstly, a static IP provides better network stability since your device always has a consistent address, reducing potential disruptions. Secondly, it enables easier access to services such as remote desktop connections, VPNs, and hosting servers. With a static IP, you can rely on a consistent address to access these services reliably.

Checking Network Interface Details

Before we proceed with configuring a static IP, let’s first identify the network interface details of your Ubuntu system. This information is crucial for configuring the correct network interface.

  1. Open the terminal by pressing Ctrl+Alt+T simultaneously.
  2. Type the following command and press Enter:

This command will display a list of network interfaces along with their respective details. Note down the name of the network interface you wish to configure with a static IP. It is typically labeled as “eth0” for Ethernet connections or “wlan0” for wireless connections.

Configuring a Static IP Address

Now that we have the necessary information, let’s proceed with configuring a static IP address on Ubuntu. Please follow the step-by-step instructions carefully.

First, open the network configuration file using a text editor with root privileges. In the terminal, execute the following command:

sudo nano /etc/netplan/01-netcfg.yaml

Within the file, you will find a section for your network interface, indicated by the name you noted earlier (e.g., “eth0” or “wlan0”). Modify the following lines to configure your static IP:

dhcp4: yes

Change the above line to:

dhcp4: no
addresses: [YOUR_STATIC_IP/XX] gateway4: [YOUR_GATEWAY_IP] nameservers: 
addresses: [DNS_SERVER_1, DNS_SERVER_2]

Replace [YOUR_STATIC_IP] with the desired static IP address you want to assign to your system. The /XX represents the subnet mask, which you should replace with the appropriate value (e.g., /24). [YOUR_GATEWAY_IP] should be replaced with the IP address of your network gateway. Similarly, [DNS_SERVER_1] and [DNS_SERVER_2] should be replaced with the IP addresses of your preferred DNS servers.

Here’s an example configuration:

addresses: [] gateway4: nameservers: addresses: [,]

Save the changes by pressing Ctrl+O, and exit the editor by pressing Ctrl+X.

Applying the Network Configuration

To apply the changes made to the network configuration, we need to restart the network services. In the terminal, execute the following command to apply the new configuration:

sudo netplan apply

Restart the network services by executing the following command:

sudo systemctl networking restart

Verifying the Static IP Configuration

To ensure that the static IP configuration was successful, let’s verify the changes. Now Open the terminal and execute the following command to display the network interface details:


Replace [NETWORK_INTERFACE_NAME] with the name of your network interface (e.g., “eth0” or “wlan0”).

Look for the section labeled with your interface name, where you should see the assigned static IP address, subnet mask, and other details. If the information matches the configuration you set, then congratulations! You have successfully set a static IP on Ubuntu.


Congratulations on successfully setting a static IP address on your Ubuntu system! By following this step-by-step guide, you have taken control of your network configuration, enjoying improved stability and easier access to services. Remember, a static IP offers numerous advantages over a dynamic IP, including a consistent identity and reliable access to network services.

Feel free to explore further resources to deepen your knowledge of Ubuntu networking and troubleshooting. The Ubuntu documentation and community forums are excellent places to find additional guidance and solutions to specific issues.

Enjoy your enhanced network connectivity with Ubuntu and make the most out of your stable and reliable static IP address!

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts