News
3 new Serverspace GPT API Language Models available now!
MA
May 1 2020
Updated June 20 2025

How to Configure a Network Interface in Ubuntu 18.04 Using Netplan

Ubuntu

Configuring a network interface is one of the first and most essential tasks when setting up Ubuntu Server. In this article, we’ll walk through how to manage and configure network settings in Ubuntu 18.04, focusing on both the modern Netplan method and the legacy ifupdown system. You'll learn how to locate configuration files, apply changes, handle multiple interfaces, and troubleshoot common issues — ensuring stable and reliable network connectivity for your server:

Configuring the network interface in Ubuntu 18.04 was a surprise to many. Although there exists, familiar to all, the configuration linux network interfaces file - /etc/network/interfaces, it says:

Screenshot 1: Configuring the network interface in Ubuntu 18.04 - start

Configuration via ifupdown has been replaced by netplan. Configuration via/etc/netplan. If you want to go back to ifupdown configure via command:

sudo apt install ifupdown

We will not install anything else. Set up what there is. First, look at the content of the directory /etc/netplan.

Screenshot 2: Configuring the network interface in Ubuntu 18.04 - check /etc/netplan/

Let's see, what is in this file.

Screenshot 3: Configuring the network interface in Ubuntu 18.04 - check /etc/netplan

The configuration file is written in YAML. The settings shown in the example above were made at the stage of installing the operating system. Let's take a closer look.

  • network — beginning of the network configuration block;
  • ethernets — this parameter reports that the next step will be to configure the protocol of the same name;
  • enp0s3 — the name of the configurable network interface. It is likely that in your case the name will be different. A list of all interfaces can be viewed with the command ifconfig -a;
  • addresses — block of IP addresses assigned to an interface with a network prefix. One ip-address is indicated as in the example, several addresses are indicated in square brackets “[and]”, separated by commas;
  • gateway4 — IPv4 network gateway;
  • nameservers — name server configuration block.
  • addresses — it is in the nameservers block that indicate which DNS servers to access. Indicated without a network prefix. Several addresses are indicated in square brackets “[and]”, separated by commas.
  • version — YAML language version.

We activate the current settings with the command:

netplan apply

We examined the main options. More setup examples are on the official website.

What if the system does not use netplan?

It's the old fashioned way. First we get a list of available interfaces:

ifconfig -a

Screenshot 5: Configuring the network interface in Ubuntu - available interfaces

In this case, there are 2 network interfaces without IP addresses (for now). Configured by DHCP. Let's move on to the settings.

sudo nano /etc/network/interfaces

Screenshot 6: Configuring the network interface in Ubuntu - interface settings

A server receiving IP from a DHCP server is not a good solution. We bring the file to the form:

Screenshot 7: Configuring the network interface in Ubuntu - DHCP remap

What does this mean.

  • auto enp0s3 — automatic launch of a specific interface;
  • iface enp0s3 inet static — reports on static configuration;
  • address 10.10.2.6 —actually, the IPv4 address for this interface;
  • netmask 255.255.255.0 — netmask.
  • gateway 10.10.2.1 — IPv4-gateway
  • dns-nameservers 8.8.8.8 — specify DNS servers

The second and subsequent interfaces are configured in the same way or configured using a DHCP server. Apply settings:

sudo /etc/init.d/networking restart

Screenshot 8: Configuring the network interface in Ubuntu - apply and restart

If everything is done correctly, then we wait for the process of restarting the service.

Important. It happens that the settings file is correct, but the server does not change the IP address. In this case, restarting the server with the command helps:

sudo reboot

FAQ: Network Interface Configuration in Ubuntu 18.04

  • Q: Why is Netplan used instead of /etc/network/interfaces in Ubuntu 18.04?
    Starting with Ubuntu 17.10, Netplan replaced the traditional ifupdown system for configuring network interfaces. It uses YAML-based configuration files located in /etc/netplan/ and works with backend renderers like NetworkManager or systemd-networkd.
  • Q: How can I find my network interface name?
    You can list all available interfaces using the command ifconfig -a or ip link show. Interface names like enp0s3 or ens160 may vary depending on your hardware and system.
  • Q: What should I do if my network changes don’t apply after editing the Netplan config?
    After making changes in the YAML file, run sudo netplan apply. If the IP address still doesn’t change, try restarting the system with sudo reboot.
  • Q: Can I still use the old /etc/network/interfaces method?
    Yes, but you need to install the ifupdown package manually with sudo apt install ifupdown. However, it’s recommended to stick with Netplan on Ubuntu 18.04 for compatibility.
  • Q: How do I set up a static IP address?
    In Netplan, specify the addresses, gateway4, and nameservers fields in your YAML config. For the legacy method, use iface [interface] inet static in /etc/network/interfaces.
Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.