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

Issue with installing python-axolotl or python-axolotl-curve25519 on Windows

It is peeve amazing how many hours get burnt while trying to resolve simple package dependency issues. I may be too dumb to proffer a lasting one-fits-all solution to all dependency issues, but I got this issue fixed in my own case. Problem Description: The python-axolotl library requires certain dependencies that are not properly managed when installing libraries via a command line's requirement.txt file. I got real help by reading through this link below, but this page might be more helpful when it comes to detailed instructions. Actual instructions: https://github.com/tgalal/python-axolotl Typical errors might look like the following: 1. In this case, missing library(s). Libraries needed for compiling some python resources. Unfortunately, http://aka.ms/vcpython27  has been decommissioned because Python2x is EOL. You can still get the VcPython27 from an archive at https://web.archive.org/web/20210106040222/download.microsoft.com/download/7/9/6/796EF2E4-801B-4F...

Chrome Extension (part 1): Injecting External Scripts into a Web Page

Recently, I was required to develop a chrome extension for some executives. This plugin only targeted a few of our most visited websites. There was a lot of approaches to implement the extension and all our use cases. One particular challenge was trying to inject scripts from our own CDN into specific web pages. the scripts were required to interact with the page and all variables possible. Since there is a script isolation thing for Chrome Extensions, I felt this was a good challenge to take up in my spare time. Here is a sample of my content script. content.js document.onreadystatechange = function () { console.log("document state is:" + document.readyState); if (document.readyState == "complete") { let randAntiCache = Math.random().toString().split('.')[1]; let scriptURL4="http://localhost.test/testscript.js?v="+randAntiCache; let scriptnode4 = document.createElement("script"); scriptnode4.setAttribute("s...

Who is this Brown Skin Girl?

In the recent wake of a great musical sensation and a re-make of the famous Lion King movie, Beyonce has been on the global selection of artistes to share performances. Today, I will try to examine the poetry of the track titled Brown Skin Girl, All interpretations in this article are my personal candid opinion. so feel free to share yours in the comments section, i will be glad to add it to my edits. So while I may not pretty boy; your heart is amiss; Play it like a villain `cause she caught in a wave This paints the picture of a guy who feels He is not good enough for the lady of his dreams, so he said Tonight I am walking away Lined up my mind, on the grind yeah yeah meaning he tryin' to give up. But then in the chorus, He said Tonight I might fall in love Depending on how you hold me I'm glad that I'm calming down can't let no one come control me So this dude aint feeling he's the kinda guy for bae, but bae be doubting if she still want...