❤️ ABS is one of the five Certified Kubernetes Service Providers in India ❤️

Setting a Static IP Address on a Linux Machine

In the world of Linux networking, there are times when you want your machine to have a stable, unchanging IP address. This is known as a static IP address.

In this guide, we’ll walk you through the steps to set up a static IP address on a Linux machine.

  1. Determine Your Network Interface
  2. Edit Network Configuration
  3. Configure the Static IP Address
  4. Apply the Configuration
  5. Verify the Configuration
Step 1: Determine Your Network Interface

Determine the network interface you want to configure

					#Run either of these commands to list the available network interfaces
ip a

The primary one is often named something like eth0 (for Ethernet) or wlan0 (for Wi-Fi). You’ll need this information for the next steps.

Step 2: Edit Network Configuration

Now that you know your network interface, it’s time to open and edit the network configuration file for that interface. You’ll find these configuration files in the /etc/netplan/ directory. You can use a text editor like nano or vi to edit the file.

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

Step 3: Configure the Static IP Address

Inside the configuration file, you’ll see YAML code defining your network settings. By default, it might look something like this:

 version: 2
 renderer: NetworkManager
     dhcp4: yes


To set a static IP address, you’ll need to change the dhcp4: yes line. Here’s an example of what your configuration might look like for a static IP address:

 version: 2
 renderer: NetworkManager
     addresses: []
       addresses: [,]

  • addresses:  Set your desired static IP address and subnet mask.
  • gateway4:  Set your router’s IP address as the default gateway.
  • nameservers:  Set DNS servers.
Step 4: Apply the Configuration

Apply the changes you made to the network configuration using the following command:

					sudo netplan apply
Step 5: Verify the Configuration

To ensure that your Linux machine now has a static IP address, use the ip a or ifconfig command in the terminal. This will display the network configuration for your chosen interface, and you should see your newly configured static IP address.