Debian – How to fix Debian that refuses to connect to the internet in VirtualBox

debiannetwork-interface

The way Linux is designed, once you lose internet connection you're screwed. Because without internet, you can't install programs, and you just might need some programs to set up internet.

Debian with xfce has no built-in gui to ensure this problem is even more dangerous. I'm not sure what exactly did I do wrong, but my Debian in Virtual box stopped communicating with virtual network card after I cloned it, which I think is related to the mac address change. I tried to restart it while altering the virtual box card settings, but nothing happened.

Windows alternative of ipconfig seems to be ip, and I get this for ip a:

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 08:00:27:98:5a:42 brd ff:ff:ff:ff:ff:ff

That seems like the interface is turned off. That's itself strange, the hardware is connected on the virtualbox side. The mac address matches virtualbox setting, so the address had to be loaded from the hardware.

Is there any way to configure network connection like I can do in windows? For example to see whether the hardware is found whether it communicates with dhcp and so on?

Best Answer

Two pieces to this answer (actually, networking is trivial in *Nix).

If you have correctly configured VirtualBox, then

ip link set dev eth0 up
dhclient -v eth0

(you might have to omit the -v flag in non-Debian distros) will connect you to the local dhcp.

If this does not work, make sure VirtualBox gave you an Internet connection, checking that your VM has a network adapter, that it is on NAT or it is a bridge adapter (in which case you will have to make sure you are trying to bridge the V; with the host's true NIC, be that wlan0 or eth0). If necessary, you may try changing the card MAC address, and repeat the above after restarting the VM (otherwise there can be no change of MAC address).

This should be automatic, try restarting the network manager to see what is going on.

service network-manager restart
systemctl restart network-manager

depending upon your version of Debian. You then test whether there are problems by means of

service network-manager status
systemctl status network-manager

and, if it is not running, you will have to search for error messages in /var/log, especially in daemon.log. But a catch-all command is

grep -nrI network-manager | less

with output parsed because it is bound to be copious.

Related Question