Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running Ubuntu Server 12.04 LTS 64 bit in Virtual Box. There are two network adapters attached with it. eth0 (primary) is using NAT & eth1 is using bridge.

I am able to connect to internet using eth0 thanks to NAT. Now, I want to access website hosted in it from host OS (Windows 7 Home Premium 64 bit). I don't know how to do it with NAT. So, I was trying to do it with eth1.

This is what I am thinking: eth1 has access to physics WiFi adapter. After connecting to WiFi router, I'll get internal IP of VM using which I can access the website. Correct me if I am wrong.

Now, my problem: There's no wlan0 type interface listed when I run ifconfig -a. And, iwconfig isn't working on eth1. Please, help.

Step by Step guide is encouraged as I don't know even where to enter wifi password & SSID.

share|improve this question
    
On Ubuntu vm, check your /etc/network/interface file. It lists all nic your vm has. Also, I don't think you should use wifi to access host website from vm, it should be accessible through NAT itself. What happens when you type the host website url in firefox? –  Prahlad Yeri Aug 11 '12 at 22:21
    
@PrahladYeri How can you make an URL to resolve at a IP when you don't have IP at all?? –  user178094 Aug 15 '12 at 6:24
    
To assign/check the IP, check the /etc/network/interface file. It both lists the ip each interface has (static/dynamic), but also allows you to specify or change it. Look here for more details: wiki.debian.org/… –  Prahlad Yeri Aug 15 '12 at 10:43
    
@PrahladYeri Those IPs aren't accessible from Host OS when you use NAT.. –  user178094 Aug 15 '12 at 20:16
    
In order to access your guest machine from the host on specific IP/port combination, you will have to issue specific commands. See my answer below. –  Prahlad Yeri Aug 17 '12 at 10:05

2 Answers 2

up vote 0 down vote accepted

In the NAT mode of VirtualBox, in order to access your guest OS from the host OS, you have to specifically enable port-forwarding by issuing specific commands like these:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

See this VirtualBox manual link for more details https://www.virtualbox.org/manual/ch06.html#natforward

share|improve this answer
    
I want to forward all ports by dynamic forwarding. How to do that??.. –  user178094 Aug 20 '12 at 18:33

You shouldn't need the second adapter just to connect to the host, though sometimes it is useful to configure it as a Host-Only adapter (instead of a bridge) such that your host can also communicate with the guest.

Using just the NAT adapter, you should be able to connect to the guest's default gateway - in my case the guest is an Ubuntu 12.04 VM configured with a single adapter in NAT mode. The automatically assigned IP address by DHCP for the guest is 10.0.2.15 and the gateway is configured as 10.0.2.2. If I use Firefox to connect to 10.0.2.2 I see the default web page for the web server running on my host operating system and I can browse to any pages.

share|improve this answer
    
How do you suppose to ping IP of VM when you are connected with NAT? –  Sachin Shekhar Aug 13 '12 at 13:19
    
The server is running on Guest OS, not Host OS. And, also I don't have IP of VM accessible from Host OS what @SachinShekhar said. –  user178094 Aug 15 '12 at 6:26
    
Configure two virtual adapters, one configured for NAT (for internet access) and one as a Host-Only adapter to provide a stable link between host and guest. –  Goyuix Aug 15 '12 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.