I have a VirtualBox virtual machine. The host machine runs Ubuntu. The guest (virtual) machine runs Windows XP.
I googled this problem, and people claim that they fixed it by changing adapter type to NAT, but there is no such option for me:
Any idea?
Update:
It didn't work either, after just switching it to NAT. Here are the current settings (with all details shown):
Here's a screenshot of the guest showing some networking information:
(Please note that this question is about how to give a VM Internet access in VirtualBox, so the presence of a picture of Windows doesn't automatically make this off-topic!)
Best Answer
Setting Up NAT
NAT is not an option for Adapter Type. Rather, it's an option for Attached to.
Click where it currently says Bridged Adapter and you should be able to select NAT.
By the way, the reason changing it to NAT sometimes helps is not specific to Windows guests. Rather, if your physical (host) PC is on a LAN, Bridged Adapter (as well as NAT) usually works fine. If your physical PC has a network connection for just one computer--as is often the case if it's plugged directly into a cable/DSL/ISDN modem that only has one Ethernet port on it--then there is no local network to bridge to, so then you must use NAT.
If you use Bridged Adapter and your host machine is on a physical LAN, your guest machine will automatically be able to see and be seen by computers on the LAN. If you use NAT on a LAN, the guest machine will be able to see the other computers on the LAN but the other computers on the LAN (besides the virtualization host) will not be able to see it.
If you're interested in more details, see these articles on network bridging and network address translation.
If that works, great. Otherwise...
Check the Guest's Network Configuration
In the virtual machine, open the Network Connections configuration (from the Control Panel or in Start Menu > Settings). Unless you've manually configured multiple interfaces for the guest machines in VirtualBox (or have actual network adapters attached to it with USB forwarding), you'll see just one, and unless you've changed its name, it will be called Local Area Connection (perhaps with a number after it).
Right-click on that and click Properties.
Under The connection uses the following items, click Internet Protocol (TCP/IP) and click Properties.
Make sure the configuration is correct.
For Bridged Connections
If you kept the VM's network adapter bridged in VirtualBox, rather than switching it to NAT, then it is as if there is a layer 2 network switch connecting three devices:
So, your VM is "networkologically" equivalent to your host machine. Whatever settings it has (except its IP address of course), your virtual machine should have.
For NAT Connections
If you selected NAT for Attached to in VirtualBox, then it's like your real computer is acting like a small home/office router. Your host machine runs a DHCP server that is accessible only to VirtualBox virtual machines, and the guest gets all its network configuration information from it.
The VirtualBox DHCP server will provide both an IP address and DNS information to the guest, so both of these two options should be selected:
This is the key.
This is the particular problem, for the system in this question. If this is the only problem with the configuration, then fixing this should solve the matter entirely.
You have manual settings, rather than DHCP.
That can work, but the manual settings would need to be correct, and you'd also want to make sure the IP was not in the range of IP addresses that your router assigns from (or there could be a collision with another device on the network).
In this case, the manual settings are not correct at all, because:
The host machine's IP address on the network interface through which it provides an Internet connection to the guest is not the same as its IP address on the physical network. Even if your computer's IP address is 192.168.1.1 "in real life," the guest cannot access it that way.
But the guest cannot directly access the physical NAT router on your desk (or wherever), because any data transmitted between the VM and the real router must go through the VM's router, and the VM's router is your computer (accessed through that special virtual network interface).
Since the default gateway is wrong, no routing occurs and the VM cannot access any physical network devices outside your computer.
Since the VM's IP address is outside the correct range (which is usually 10.2.2.*) and the subnet mask is 255.255.255.0, it cannot access the correct range. (The subnet mask is correct, but together with the IP it identifies the wrong subnet.)
The DNS server must also be fixed or no hosts can be accessed through their domain names (like askubuntu.com).
If for some reason you need to use a "static IP," i.e., not use DHCP, then you'll have to get the correct information from VirtualBox and input it. Please let me know if you need help with that (I can expand this to include instructions).
Assuming DHCP is okay with you, you can solve the problem by making your Internet Protocol (TCP/IP Properties), General tab settings look like the screenshot above.
Still No Internet Connection? Time to Troubleshoot
It may help to gather some more information from the guest side. In the virtualized Windows XP system that is mysteriously not connecting to the Internet, install the VirtualBox guest additions (by clicking Devices > Install Guest Additions; see the manual for more information). Reboot, and see if you can connect to the Internet. If you cannot, you've still accomplished something useful, because now you can copy and paste between the guest and host clipboards.
So open the Command Prompt in Windows. One way to do that is to run:
Now run this command to get information about the Windows guest system's network interfaces and connections.
Then copy all the text in the command prompt to the clipboard. This functionality is accessible in the contextual menu raised by right-clicking anywhere inside the command prompt window. You can then edit your question on your Ubuntu host system where you have a working Internet connection, and paste it in.
More generally, for people other than the asker of this question:
You can then paste it into applications in your Ubuntu host system, permitting you to refer to it when your Windows VM is suspended/off. You can provide it to whoever is trying to help you. You can include it in your own question here on Ask Ubuntu
(However, if your network problem is in the virtual installation, rather than the virtual hardware or the VirtualBox software--for example, if your VM accessed the Internet fine until you installed some Windows software other than the guest additions--then your problem would likely be considered off- topic for Ask Ubuntu. It would likely be on-topic for Super User though.)