Software & AppsOperating SystemLinux

How To Switch Back to /etc/network/interfaces in Ubuntu 18.04

Ubuntu 20

In this article, we will discuss how to switch back to the traditional /etc/network/interfaces method for configuring the network in Ubuntu 18.04, instead of using the newer netplan approach.

Quick Answer

To switch back to using the traditional /etc/network/interfaces method for configuring the network in Ubuntu 18.04, you need to reinstall the ifupdown package, configure the /etc/network/interfaces file with your desired network settings, make the configuration effective using specific commands, disable and remove netplan-related services, update the DNS resolver configuration, and restart the systemd-resolved service.

Introduction

Ubuntu 18.04 introduced a new method of network configuration called netplan. However, some users may prefer the older, more familiar method of configuring network interfaces using the /etc/network/interfaces file. Here, we will guide you through the process of reverting back to this method.

Reinstalling the ifupdown package

The first step is to reinstall the ifupdown package, which provides the ifup and ifdown commands used for configuring network interfaces. You can do this by running the following commands in the terminal:

# apt-get update
# apt-get install ifupdown

The apt-get update command updates the list of available packages from the repositories, while apt-get install ifupdown installs the ifupdown package.

Configuring the /etc/network/interfaces file

Next, you need to configure the /etc/network/interfaces file with your desired network settings. Here’s an example configuration:

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
 address 192.168.1.100
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-nameservers 8.8.8.8 8.8.4.4

In this file, auto is used to bring interfaces up at system startup. iface is used to define the configuration for an interface. The inet keyword is followed by either static or dhcp, depending on whether you want to use a static IP address or obtain one automatically via DHCP.

Making the configuration effective

To make the configuration effective without rebooting, run the following commands:

# ifdown --force eth0 lo && ifup -a
# systemctl unmask networking
# systemctl enable networking
# systemctl restart networking

The ifdown and ifup commands bring network interfaces down and up, respectively. The --force option forces the commands to run even if there are errors. The systemctl commands are used to manage the networking service.

Disabling and removing unwanted services

Next, you need to disable and remove the services related to netplan:

# systemctl stop systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl disable systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl mask systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# apt-get --assume-yes purge netplan.io

These commands stop, disable, and mask the systemd-networkd and networkd-dispatcher services, which are used by netplan. The apt-get purge command removes the netplan.io package and its configuration files.

Updating the DNS resolver configuration

Finally, you need to update the DNS resolver configuration by editing the /etc/systemd/resolved.conf file:

DNS=8.8.8.8 8.8.4.4

Then restart the systemd-resolved service:

# systemctl restart systemd-resolved

This updates the system’s DNS resolver to use Google’s DNS servers (8.8.8.8 and 8.8.4.4).

By following these steps, you can remove netplan and switch back to using /etc/network/interfaces for network configuration in Ubuntu 18.04. Remember to adapt the values in the configuration file according to your specific network setup.

Conclusion

Switching back to the traditional method of network configuration in Ubuntu 18.04 may seem daunting, but with these steps, it can be a straightforward process. Remember, it’s always important to back up any important data before making significant system changes. Happy networking!

Can I switch back to using /etc/network/interfaces in Ubuntu 18.04?

Yes, you can switch back to using /etc/network/interfaces in Ubuntu 18.04 by following the steps outlined in this article.

What is the difference between netplan and /etc/network/interfaces?

Netplan is a newer method of network configuration introduced in Ubuntu 18.04, while /etc/network/interfaces is the traditional method. Netplan uses YAML files for configuration, while /etc/network/interfaces uses a plain text file. Netplan also provides more flexibility and advanced features compared to /etc/network/interfaces.

Why would I want to switch back to using /etc/network/interfaces?

Some users may prefer the familiarity and simplicity of the /etc/network/interfaces method for configuring network interfaces. It may also be necessary to switch back if you are using software or tools that are not compatible with netplan.

Will switching back to /etc/network/interfaces cause any issues?

Switching back to /etc/network/interfaces should not cause any issues if done correctly. However, it is always recommended to backup your important data before making any significant system changes.

Can I switch back to netplan after switching to /etc/network/interfaces?

Yes, you can switch back to netplan if you decide to revert the changes. Simply follow the instructions provided by Ubuntu’s documentation or consult relevant resources on how to configure netplan.

How do I update the network settings in /etc/network/interfaces?

To update the network settings in /etc/network/interfaces, you need to edit the file using a text editor and modify the desired configuration parameters such as IP address, netmask, gateway, and DNS servers. Save the changes and then restart the networking service for the new settings to take effect.

Do I need to restart my computer after switching back to /etc/network/interfaces?

No, you do not need to restart your computer after switching back to /etc/network/interfaces. You can make the configuration effective without rebooting by following the steps outlined in the article.

Can I use both netplan and /etc/network/interfaces simultaneously?

No, you cannot use both netplan and /etc/network/interfaces simultaneously. Ubuntu uses netplan as the default method for network configuration in 18.04, so if you switch back to /etc/network/interfaces, netplan will be disabled.

Leave a Comment

Your email address will not be published. Required fields are marked *