Set up a network carefully when using Linux with VirtualBox

Let’s imagine a simple scenario: you have just installed Debian 9 but you have forgotten to select a network options within VirtualBox.  Most likely  your linux system won’t be able to use a network  because it didn’t set up default network setting due installation.

As a result you will be facing with with the similar error when trying execute sudo apt-get update command

chip@chip:~$ sudo apt-get update
[sudo] password for chip:
Err http://ftp.us.debian.org jessie InRelease
Err http://security.debian.org jessie/updates InRelease
Err http://http.debian.net jessie-backports InRelease
Err http://opensource.nextthing.co jessie InRelease
Err http://security.debian.org jessie/updates Release.gpg
  Could not resolve 'security.debian.org'
Err http://http.debian.net jessie-backports Release.gpg
 Could not resolve 'http.debian.net'
Err http://opensource.nextthing.co jessie Release.gpg
  Could not resolve 'opensource.nextthing.co'
Err http://ftp.us.debian.org jessie Release.gpg
  Could not resolve 'ftp.us.debian.org'
Reading package lists... Done
W: Failed to fetch http://ftp.us.debian.org/debian/dists/jessie/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease
W: Failed to fetch http://http.debian.net/debian/dists/jessie-backports/InRelease
W: Failed to fetch http://opensource.nextthing.co/chip/debian/repo/dists/jessie/InRelease

Don’t worry, it is not a trouble at all! It means that linux doesn’t know about your networks adapters yet.  You just need to configure default network uses.  To confirm this type ping 8.8.8.8 and you should see some error message.

The steps you need to fix error will be these:

Turn on the NAT network adapter option inside the VirtualBox settings menu

Execute ip addr and choose network interface which you want to activate. In my case it is

Execute dhclient [your interface name] and default network will be changed.

To keep network setting  activated when you has been restarting the system you need also add some config settings. Type nano /etc/network/interfaces and add lines highlighted on the picture below:

Leave a Reply

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