4

I am trying to figure out why my guest cannot connect to the internet while attached to the NAT network. I have provided some screenshots of the settings below. I am only having this issue on lubuntu. Both my friend and I can get this working on 2 different Linux systems with all the default settings and no tinkering.

Doing ifconfig on the guest shows me that there has been an IP assigned in the range shown in the first pic below(it just defaults to this). Apart from what is shown below, I have not changed any settings from their defaults.

Incidentally, I am having the same problem with any VM I install on VirtualBox with lubuntu as host OS. Bridged and Host-Only connections work fine.

VirtualBox Preferences:

VirtualBox preferences

Guest Network settings:

Guest Network settings

EDIT:

Some information on the system and network setup:

cat /etc/network/interfaces

auto lo
iface lo inet loopback

Guest OS: lubuntu 17.04

Host OS: lubuntu 17.04

VirtualBox Version: 5.1.22_Ubuntur115126 (output of VBoxManage --version)

(Sorry for capturing the entire screen.. my screen capture tool can't take close-ups from a VM) ifconfig -a: enter image description here

route -n: enter image description here

arp -n: enter image description here

12
  • askubuntu.com/questions/232876/… See this link. maybe this will work Oct 23, 2017 at 12:58
  • 1
    @Totem You may already be aware of this, but there's a difference in VirtualBox between a "NAT" adapter and a "NAT Network" adapter. Do you specifically want to use the "NAT Network" adapter or do you just want to access the internet?
    – igal
    Oct 23, 2017 at 13:50
  • @Totem See the following (somewhat dated) blog post related to VirtualBox NAT Networks: jekewa.com/blogs/index.php/weBlog/2014/01/09/…
    – igal
    Oct 23, 2017 at 13:56
  • What exactly do you mean by 'cannot connect to the internet'? Could you post the output of traceroute 151.101.1.69?
    – sborsky
    Oct 23, 2017 at 14:34
  • @igal Either of those would be fine. Thanks for the article, I now understand the real difference between NAT and NAT Network. Neither work though...
    – Totem
    Oct 23, 2017 at 20:01

1 Answer 1

3

Update: To summarize, you were using a NAT-Network/NAT-Service interface. This is a distinct interface type from the similarly named NAT Interface. The differences are described well in this blog post:

When you switched from a NAT-Network Interface to a NAT interface you were able to access the internet from your VM without additional configuration. Since this was your ultimate goal, we didn't continue to diagnose what was causing trouble for your NAT-Network interface.

The original solution follows.


I don't know enough to make a certain diagnosis based on the information you've provided so far, but one possibility is that there's a conflict between the VirtualBox network configuration on the host and the network configuration on the guest.

I suggest trying to start from a working NAT configuration with port-forwarding to allow for SSH access to the guest. There are several reasons for this:

  1. You aren't able to copy text from the guest in your current situation.

  2. It is often helpful in debugging to start from a situation in which everything is working and then work your way back towards the problem.

  3. In my experience is the NAT interface is the most painless and least error-prone method of getting internet access for a VirtualBox guest.

You can do this via the GUI, but I'll include command-line examples for concreteness.

First let's remove all of network interface cards:

for n in 1 2 3 4 5 6 7 8; do
    vboxmanage modifyvm "${VMNAME}" --nic${n} none
done

Now let's add a single NAT interface:

vboxmanage modifyvm "${VMNAME}" --nic1 NAT

Let's sanity-check the NIC configuration:

vboxmanage showvminfo "${VMNAME}" | grep '^NIC'

The output should something like this:

NIC 1:          MAC: 08002784C3DE, Attachment: NAT, Cable connected: on,
                Trace: off (file: none), Type: Am79C973, Reported speed: 0
                Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings: MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Now let's add a port-forwarding rule for ssh. Here is an example which maps port 2222 on the host to port 22 on the guest:

vboxmanage modifyvm "${VMNAME}" --natpf1 ssh,tcp,,2222,,22

Boot the VM and test the SSH connection. If you already have SSH running on the guest then you can boot it in headless mode:

vboxmanage startvm --type headless "${VMNAME}"

Log in to the guest via ssh:

ssh -p 2222 localhost

Note that due to the port-forwarding rule you don't need to know the IP address of the guest. If you get this working then you can update your post and we can try to figure out what was wrong with the "NAT Network" configuration.

Also, you might want to try downloading a preconfigured VM from the Virtual Boxes website. Apparently they have some lubuntu images.

7
  • 1
    By Jove, adding the NAT interface did it! I didn't need to do anything with port-forwarding. I had an inkling before that this could be the issue, but didn't pay enough attention. For some reason it appears lubuntu doesn't set up the interface needed for NAT on the host machine.. whereas other OS's seem to set it all up by default. Thank you for the effort you put into answering my question! If you like you could edit out that parts about port-forwarding and ssh, to focus on the bit that solved it for me. I'm accepting this either way.
    – Totem
    Oct 25, 2017 at 19:30
  • Just to clarify. In your update you say "When you switched from a NAT-Network Interface to a NAT interface you were able to access the internet from your VM without additional configuration". Originally neither of these was working. Adding the interface via the terminal, as per your solution, seems to be what did it (This only seemed necessary on lubuntu in my experience). I must admit, I have not tested whether this works with "Nat network", but it sure works for "NAT".
    – Totem
    Oct 28, 2017 at 23:28
  • @Totem Ah. Then I'm really unclear on what the actual problem was. When you tried using the NAT interface by configuring the VM via the GUI, did you remove the other interfaces first?
    – igal
    Oct 28, 2017 at 23:46
  • Yes I did, as per your instructions. However, I checked first with 'ifconfig -a' and I do not believe there were any interfaces (for virtualbox) there to begin with(certainly none showed up with ifconfig -a), and that this was the problem. Apparently, unlike most other OS's, lubuntu for some reason did not create these for me automatically. At least, this is my understanding. lubuntu certainly is a very shaved down version of Ubuntu, and so lacks many things that may be considered 'basics' in Ubuntu. For instance, even ifconfig itself isn't available in a fresh install of lubuntu.
    – Totem
    Oct 29, 2017 at 12:58
  • 1
    ifconfig not being available might just be because you're using a newer version OS. The net-tools package (of which ifconfig is a part) has been deprecated by many distributions (c.f. Where is the statement of deprecation of ifconfig (on linux)?). The net-tools package has largely been replaced by the iproute2 package. I believe that the replacement command for ifconfig would be ip addr.
    – igal
    Oct 29, 2017 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.