Skip to main content

Ubuntu: Unable to get IP for network interface / Using multiple network adapters

This is a very focused article on a similar issue which i encountered very recently.

Problem: I recently installed Ubuntu Server 20.0 on a virtualBox. My intention was to use 2 network adapters as shown in the picture below.
  1. Host-Only Network
  2. NAT
After setting up, I realised that i could not get IP address for the NAT adapter and it was always DOWN.

Solution: Ubuntu20.0 comes with a different Newtork Configuration System compared to older ones like Ubuntu 14. The new Ubuntu uses netplan to handle network configurations.
To solve this issue, you need to add specific information about every adapter into the netplan configuration file. The first adapter will always be configured by default.

Follow through this article to learn how in 5 easy steps.

1. The picture below shows that my VM is already configured to use 2 network adapters.




2. Now i powered up the VM and check my network parameters.
I powered the VM and ran the commands to check if my 2 network adapters were functional.

ip addr


Here's the result below:
This impllies that my Host-Only Network(enp0s3) is fine and running at 192.168.56.101.
But this also shows that my second network adapter interface is down. Dont try running a command to bring it up because it will still not be functional and it will go down again after reboot.

3. Remember I mentioned Netplan. The netplan config file is any
.yaml
file in the netplan directory.
Netplan Directory:
/etc/netplan/

from the previous step, observe that
enp0s3
refers to my Host-Only Network interfcae, while
enp0s8
refers to my NAT interface. Lets open the netplan config files to see the default configuration.

As you can see, only my HostOnlyNetwork is configured, I need to add an additional entry for my new interface.

4. Be careful when handling yaml files, they have strict indentation pattern, and any little mistake means the configuration file will not be useful to the System.
You must be the root user before you can edit the netplan configuration yaml files.
Sample Commands:
nano /etc/netplan/00-installer-config.yaml

Copy the file contents and paste on the next line.
Change the interface name on the new entry so that it shows the name of your second adapter.
when you are done press
Ctrl+X
to save, press
Enter
to ensure the file name remains same.

The picture above shows that I duplicated the initial content of the file and simply changed the interface name for enp0s8 before saving the yaml file.

5. Now Reboot your Virtual machine.

6. Now run the command to show your network interfaces again.
ip addr

As you can see, the NAT Adapter interface is now showing and it also has an IP address. the NAT adapter will allow this VM talk to the internet and also other VM on the same virtualBox.
The HostOnly Network will ensure the the Host computer can ssh into the VM at anytime.

Thats all. At present I am not sure why only the first interface is configured by default but it was nice to see this solved. I hope this article helps you. Feel free to reach out to me. Love you and thanks for reading. We can also set the DHCP4 to false. Detils will be provided in a future article.

Comments

Popular Articles

Laragon: installing more versions of Apache/HTTPD

Most of the time, we casually install various PHP versions and server tools without checking if they were built for Win32 or Win64. A discussion for another day. I recently downgraded Laragon’s from PHP8.1-x64 to PHP7.x-x86. This had a little consequence - APACHE! Hence, I got the error below, indicating that my PHP and Apache can’t work together because they are of different architectures or builds.   The originally installed Apache was for 64-bit PHP versions, there are no Apache versions designed to run both 32-bit and 64-bit builds of PHP. In this article, I share steps and links that guide you to install multiple versions and builds of Apache on Laragon. 1. For all intent and purposes, you are advised to always download the latest version of Apache. Visit this URL https://www.apachelounge.com/download/additional/ to see the different versions available. It is easy to access the 64-bit versions from the homepage. However, to access the 32-bit versions, you need to use this URL. 2

Resolving Incompatible Builds of PHP and Apache in Laragon: Add multiple versions of Apache

 As developers, it's often the case that different versions of PHP and server tools are installed quickly without taking into account the architecture for which they were built. In this article, we will focus on solving a specific error that arises when running incompatible builds of PHP and Apache. Recently, I encountered an issue when downgrading my Laragon setup from PHP 8.1 (x64) to PHP 7.x (x86). This caused compatibility problems with Apache, and I received an error message indicating that my PHP and Apache builds were not compatible, as the Apache installed was built for x64 versions of PHP. In this article, I'll provide a step-by-step guide on how to install multiple versions of Apache on Laragon. By following these steps, you can resolve any similar issues that you may encounter. Step 1: Download the Latest Version of Apache Visit https://www.apachelounge.com/download/additional/ to download the latest version of Apache. The homepage provides quick access to 64-bit ve

VS CODE: Unable to install extensions on Ubuntu/Linux

Hey, its one of those days, i just wished i could code away the night. i decided that tonight, it was going to be VS Code all through. I closed Sublime text. It was not long before I started missing the php code linting and ever intelligent code completions that were built into sublime text. I checked the suggestions on the Extensions Tab of VS Code. and there it was! Felix Becker's "PHP IntelliSense" package. To my cute surprise, Upon clicking, the extension's description and Installation "Read Me" could not display correctly, 'twas as good as blank. All i could see was this: I thought, this is something light, so i started searching but then it was not better explained except for the GitHub issue which I found to be useful, Link is at the bottom of this page.  I hate to discover it was a DNS issue. How to detect the Issue Simply visit the URL below, if you are able to view the image on the page, then you are not affected by this issue. DNS Test URL: ht