How to configure static IP using Netplan

Configuring a Static IP address using Netplan

The configuration file for Netplan(.yaml) is stored in the directory ‘/etc/netplan’. In our case, there is no config file in this directory, and no IP is assigned to the interface ‘enp0s3’:

https://sive.host/titfombe/repository/word-image-384.webp

1. Setting a Single Static IP

For setting a single static IP for a system using Netplan, create a new configuration file as ‘/etc/netplan/config.yaml’. Let us modify the interface enp0s3 with the following details:

IP address: 192.168.186.30

Gateway: default

subnet prefix: /24

Now create or open the configuration file in the directory ‘/etc/netplan/’ with the command:

sudo nano /etc/netplan/config.yaml

 

To apply the configuration, use the command:

sudo netplan apply

Now check the IP with the ‘ip’ command:

https://sive.host/titfombe/repository/word-image-391.webp

Wrapping Up

In this guide, we have learned to set static IP using Netplan. Netplan config file is very space-sensitive as it uses the YAML format. Managing networking with Netplan is quite straightforward. You will not find it tough to master once you get used to it.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

12 Useful “df” Commands to Check Disk Space in Linux

Useful df Command Examples This article explain a way to get the full information of Linux disk...

How to Disable SELinux

How to Disable SELinux You’ve setup a new system, or installed something new on your Linux...

How to set a Static IP in Ubuntu Linux

How to set a Static IP in Ubuntu LinuxOpen the terminal command line application or ssh into the...

Linux Check Disk Space Command To View System Disk Usage

Linux Check Disk Space Command To View System Disk Usage Linux command to check disk space...