How to restore network connectivity after accidentally removing on Ubuntu Cloud Servers

2023-08-24 By Nathan 3031 Views linux networking troubleshooting netplan
3 reviews

Accidentally removing essential components like from your Ubuntu cloud server can lead to the loss of network connectivity. is a Linux utility used for configuring and managing network settings on Ubuntu systems through YAML-based configuration files, simplifying the process of network setup and management. It helps users define network interfaces, IP addresses, and routing rules in a structured manner.

After encountering installation issues on Ubuntu, various attempts were made to rectify the problem using commands like apt purge, remove, autoclean, and autoremove. Unfortunately, these efforts may result in the removal of both netplan and network connectivity.

In this guide, we will walk you through the steps to recover network access and restore your server's connectivity.

  1. Utilize the ip a command to verify whether the server has an IP configuration.

    # ip a


    In the screenshot provided above, it is apparent that the server does not have any IP configuration set.

  2. Command cat /etc/netplan/50-cloud-init.yaml is used to display the contents of the 50-cloud-init.yaml file located in the /etc/netplan/ directory.

    # cat /etc/netplan/50-cloud-init.yaml

    This file is part of the Netplan configuration system on Ubuntu Linux systems and is commonly used to define and manage network interfaces and settings.


    From the screenshot above, it's evident that there are no problems with the network configuration file.

  3. Utilize the networkctl command to inspect the network card status on the server.

    # networkctl


    See that the ens3 is off in the server.

  4. Use the commands below to enable network for the server.

    # ip link set ens3 up 
    # ip address add <ip address="">/24 dev ens3
    # ip route add default via <gateway> dev ens3


    In a network setup, if the IP address is chosen as, the gateway assigned is, adjusting the last segment of the IP address to 1 designates the gateway for LayerStack server.

  5. Run the update command on the server.

    # apt update


    There is an error while running the update command.

  6. Add 2 DNS servers such as and in your /etc/resolve.conf.

    # vi /etc/resolve.conf



  7. Run update command on the server again.

    # apt update


    The update is running fine now from the above screenshot.

  8. Install

    # apt install


    Once is installed, make sure to reboot the server once. The network connection will be running smoothly.

Related Tutorials

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.