1

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.

5
  • 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? Commented Aug 11, 2012 at 22:21
  • @PrahladYeri How can you make an URL to resolve at a IP when you don't have IP at all??
    – user178094
    Commented Aug 15, 2012 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/… Commented Aug 15, 2012 at 10:43
  • @PrahladYeri Those IPs aren't accessible from Host OS when you use NAT..
    – user178094
    Commented Aug 15, 2012 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. Commented Aug 17, 2012 at 10:05

2 Answers 2

0

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

1
  • I want to forward all ports by dynamic forwarding. How to do that??..
    – user178094
    Commented Aug 20, 2012 at 18:33
0

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.

3
  • How do you suppose to ping IP of VM when you are connected with NAT?
    – user79032
    Commented Aug 13, 2012 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
    Commented Aug 15, 2012 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
    Commented Aug 15, 2012 at 14:48

You must log in to answer this question.