How to Configure Network Static IP Address in Ubuntu 18.04?

The Internet Protocol (IP) address is a crucial component of computer networking as it uniquely identifies each device connected to a network. By default, most network interfaces are configured to obtain an IP address dynamically from a router or DHCP server. However, in some cases, it is necessary to configure a static IP address.

A static IP address is an IP address that is manually assigned to a device and does not change over time unless manually reconfigured. In this article, we will discuss how to configure a static IP address on Ubuntu 18.04 and why it's important in some situations.

What Is Static IP Address And Why It's Important?

When you connect your computer or other devices like printers and servers to a network, they are assigned dynamic IPs by default using DHCP (Dynamic Host Configuration Protocol). However, there are several reasons why you may want or need your devices to have static IPs instead of dynamic IPs.

One of the primary reasons for having a static IP is stability when you have a device with dynamic IPs constantly changing its addresses, it can be challenging for other computers on the network to keep track of where that machine is located correctly. This problem can cause issues such as disrupted connections and broken services.

With a static IP address, you specify an address that devices will always be able to find your machine at no matter what else changes on the network around it over time. Another reason for having a static IP is security assigning fixed addresses can help security measures track traffic patterns from known locations more efficiently than if addresses constantly change.

Understanding Network Configuration in Ubuntu 18.04

Before proceeding with setting up a static IP address, it is important to have a basic understanding of network configuration files in Ubuntu 18.04. There are two primary configuration methods for network settings:

  • /etc/network/interfaces Used by the ifupdown package, which is the traditional method of configuring networking on Ubuntu systems. Contains interface configurations such as IP address, netmask, gateway, and DNS servers.

  • /etc/netplan/*.yaml Used by the Netplan utility for configuring networking in Ubuntu 18.04. This YAML-based configuration file provides a simple and flexible way to configure network interfaces.

Identifying Network Interface Name and Current IP Address

The first step is to identify the network interface name and current IP address. In Ubuntu 18.04, network interfaces are named differently from previous versions, so it is important to understand how to find the correct interface name.

Use the following command to identify network interfaces:

ip addr show

This command displays all available network interfaces with their IPv4, IPv6 addresses and other important information. Look for entries like enp0s3, ens33, or similar interface names. The current dynamic IP address will be shown next to inet.

Configuring Static IP Address using Netplan

Understanding Netplan YAML Structure

Netplan is the default network configuration utility in Ubuntu 18.04. It uses YAML syntax for configuration files located in /etc/netplan/. The syntax is strict, so proper indentation and formatting are crucial.

Netplan Configuration Structure network: version: 2 ethernets: enp0s3: dhcp4: no addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4

Step-by-Step Configuration Process

Follow these steps to configure a static IP address using Netplan:

Step 1: Open Terminal and navigate to the Netplan directory:

cd /etc/netplan/
ls -la

Step 2: Create a backup of the existing configuration file:

sudo cp 01-netcfg.yaml 01-netcfg.yaml.backup

Step 3: Edit the Netplan configuration file:

sudo nano 01-netcfg.yaml

Step 4: Configure the static IP address. Replace the existing content with:

network:
  version: 2
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

Replace enp0s3 with your actual interface name, and adjust the IP addresses according to your network configuration.

Step 5: Test the configuration syntax:

sudo netplan try

Step 6: Apply the configuration:

sudo netplan apply

Step 7: Verify the new configuration:

ip addr show

Configuration Parameters

Parameter Description Example
addresses Static IP address with subnet mask 192.168.1.100/24
gateway4 Default gateway for IPv4 192.168.1.1
nameservers DNS server addresses 8.8.8.8, 8.8.4.4
dhcp4 Disable DHCP for static configuration no

Troubleshooting Common Issues

If you encounter connectivity issues after applying the configuration:

  • Check YAML syntax Ensure proper indentation (use spaces, not tabs)

  • Verify network parameters Confirm IP address, gateway, and DNS settings match your network

  • Restore backup If issues persist, restore the original configuration file

  • Restart networking service Use sudo systemctl restart systemd-networkd

Conclusion

Configuring a static IP address in Ubuntu 18.04 using Netplan provides network stability and predictable addressing for servers and critical devices. The YAML-based configuration is straightforward once you understand the proper syntax and structure. Always backup your configuration files and test changes carefully to maintain network connectivity.

Updated on: 2026-03-17T09:01:38+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements