How to Configure Networking with Netplan on Ubuntu References

Wondering how to configure networking with Netplan on Ubuntu? We got you covered!

If you’re someone with experience in networking, chances are, you’ve already heard of Netplan.

For those of you who are unaware, Netplan is a tool that was designed to ease the process of Network configuration on Linux.

Netplan allows various configuration options like managing static IPs, providing IP addresses to devices, etc.

Netplan can be operated directly from the CLI. While this may seem daunting, no need to worry, as this guide is meant to help you learn how to configure networking with Netplan on Ubuntu.

That being said, let’s dive in!


Understanding Network Terminology.

Before you learn how to configure networking with Netplan on Ubuntu, it is necessary that you’re aware of some basic network terminology.

If you have some experience in networking already, you can skip this section. However, if you’re a beginner, then knowing these terms will definitely help you in the long run.

Here’s a list of terms that you’ll often encounter when configuring networking with Netplan:

  • DHCP refers to “Dynamic Host Configuration Protocol”. It is used for the dynamic allocation of IP addresses to devices so they can communicate with each other.
  • YAML is a language created for serializing data. It is used for configuration files. These files often have a .yaml extension.
  • Static routing refers to the process of manually assigning an IP to a device.
  • Interface bonding refers to linking two or more interfaces for increased bandwidth.

Now that you’re aware of some important networking terms, you can move on to the next step.


Step 1: Installing Netplan on Ubuntu.

Netplan should be available on Ubuntu versions 17 and above by default.

In case it isn’t available, you can install it with the help of the Command Terminal.

Note that we’ll be using Ubuntu 20.04 LTS in this guide. However, the steps shouldn’t differ for any other version of Ubuntu as well.

Follow these steps to install Netplan on Ubuntu 20.04 LTS:

  1. Start by opening the Command Terminal. The shortcut is Ctrl + Alt + T.
  2. Once the Terminal is open, type in the following commands:
$ sudo apt update
sudo
$ sudo apt upgrade
Configure Networking with Netplan on Ubuntu References

These commands will ensure that your version of Ubuntu has the latest packages and repositories available to it.

  1. Once the updates are finished, type the following in the Command Terminal:
$ sudo apt -y install netplan.io
Configure Networking with Netplan on Ubuntu References

This will proceed to install Netplan on your system.

If you followed these steps correctly, then congratulations. You have successfully installed Netplan on your system. All that’s left is to configure it.


Step 2: Identify Network Interfaces.

To configure any network, you need to identify the interface you wish to configure.

This can be done with the help of the Command Terminal.

Follow these steps to identify the interface that needs to be configured:

  1. First, open the Command Terminal by pressing Ctrl + Alt + T on your keyboard
  2. Once that’s done, type the following command:
$ ip a
command terminal

This will display all interfaces on the system.

With this, you’ve learned how to identify a network interface on a system.


Step 3: Configuring Network Interfaces.

Once you have identified the network interfaces, you can configure the interface using Netplan.

Network configuration can be done with the help of the Command Terminal and a text editor of your choice.

We’ll be using nano as the text editor in this tutorial. However, the method shouldn’t be different from any other text editor.

With that being said, let’s take a look at the steps:

  1. Start by opening the Command Terminal. The shortcut is Ctrl + Alt + T.
  2. Once the Terminal is open, type out the following command:
$ ls /etc/netplan
Configure Networking with Netplan on Ubuntu References

This will output the name of the configuration file.

  1. Once you have the name of the file, type the following to open it with the nano text editor:
$ sudo nano /etc/netplan/<name of file>.yaml
Configure Networking with Netplan on Ubuntu References

This will open the configuration file.

From here, you have many options for configuring your network. We’ll be going over some frequently used network configurations.

The first configuration provides an IP address to the given interface. To enable this, add the following block of text in your configuration file:

$ network:
  version: 2
  renderer: networkd
  ethernets:
    <name of the interface>:
       dhcp4: true

This will dynamically assign an IP address to the interface.

Alternatively, you can configure the IP statically as well. This requires some know-how about how networks work. To enable static routing, add the following in the configuration file:

$ network:
  version: 2
  renderer: networkd
  ethernets:
    <interface name>:
      addresses:
        - 10.10.10.2/24
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [10.10.10.10, 0.0.0.0]
      routes:
        - to: default
          via: 10.10.10.10

Apply the changes by typing the following in the Command Terminal:

$ sudo netplan apply

With this, you’ve successfully learned how to configure wired interfaces on your system.

Aside from wired connections, Netplan can also be used to configure wireless connections.


Configuring Wireless Networks Using Netplan.

Wireless network interfaces can also be configured using Netplan.

Like wired networks, wireless network configuration can be done by making edits to the configuration file.

To allow the wireless interface to connect to a WPA network, make the following changes in the configuration file:

$ network:
  version: 2
  renderer: networkd
  wifis:
    <interface name>:
      dhcp4: no
      dhcp6: no
      addresses: [<write IP address>]
      nameservers:
        addresses: [<Network address>, <DNS>]
      access-points:
        "<SSID of the network":
            password: "<password for the given network"
      routes:
        - to: default
          via: <Network address>

This script should allow you to connect to any WPA wireless network.

Another thing that Netplan can be used for is to enable network bonding. Network bonding refers to combining two or more interfaces to provide more bandwidth. Learning how to enable network bonding on Ubuntu will sure help, especially if you’re into server management.

This concludes our guide on how to configure networking with Netplan on Ubuntu. We covered some basic network terminology, methods to install Netplan, and how to configure it. If you have any questions, queries, or suggestions, let us know in the comment section down below.

If this guide helped you, please share it. 🙂

Leave a Reply

Your email address will not be published.

Previous Post

How to Kill Zombie Processes in Ubuntu

Next Post

How to Fix Wrap Text Not Working on Excel

Related Posts