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

[SOLVED] Linux - Issues installing Docker on Ubuntu - libseccomp2 version 2.3.1 installed but 2.4 required

This article has been improved for a better understanding - goto  https://splashcoder.blogspot.com/2023/07/installing-docker-on-ubuntu-1804-solved.html There is a possibility that you are trying to install docker. There is a very comprehensive guide at https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository. The linked guide serves as a reference for this article. We try to address the common errors in this article. Just so you won’t have to scour the entire answers on StackOverflow. Step 1: The first thing is to run our famous "apt update" command. So run the command below. sudo apt-get update You may observe that there are some errors. And YES! we are using a fairly old Ubuntu 18.04 Bionic Beaver Release. It seems perfect for this as most people have issues installing docker anyways. To resolve this, you may refer to  Configure DNS server IP to resolve errors with apt-get update Step 2: Following the Docker article, we should run the commands below. sudo...

Installing Docker on Ubuntu 18.04 ([SOLVED]- libseccomp2 version 2.3.1 installed but 2.4 required)

 Introduction: If you're attempting to install Docker on Ubuntu 18.04 Bionic Beaver, which is known for having installation issues, this comprehensive guide aims to address common errors you may encounter during the process. Our goal is to save you time searching for answers on StackOverflow by providing clear instructions. The guide is based on the official Docker documentation available at https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository. Step 1: Updating Package Lists To begin, run the following command to update your package lists using the "apt-get update" command: sudo apt-get update Note: If you encounter any errors during the update process, it may be due to the older Ubuntu 18.04 release. In such cases, you can refer to the Configure DNS server IP to resolve errors with apt-get update  guide for assistance. This guide will help you address any DNS-related issues that might be preventing successful updates. Step 2: Installing Dependencie...

Linux - Configure DNS server IP to resolve errors with apt-get update

Perhaps you have a new install of Ubuntu, and you are about to install docker or any other Linux packages. The first step is to update the application repositories using the sudo apt update command. There is a very small possibility that you will get the error below if you are using a fresh install of the Ubuntu 18.04 LTS (Bionic Beaver). This error simply means that Linux is unable to connect to the official repository likely due to a DNS configuration or a network issue. Here we try to help you resolve the DNS issue. To resolve this, you must specify a DNS in your network settings. Well, there is one popular DNS that works well: Google's DNS. Follow through, please. STEP 1: Go to the settings page of Linux (Ubuntu) STEP 2: This should reveal a plethora of options. On the left pane, simply scroll down and click Network as shown below. This reveals your different network connections, for me, “enp0s3” is the adapter connecter to the internet. So, I must configure DNS for “enp0s3”. ...