How to set up NAT between Windows 7 host and Ubuntu guest

Discussions related to using VirtualBox on Windows hosts.

How to set up NAT between Windows 7 host and Ubuntu guest

Postby funkimunky » 18. Oct 2010, 16:25

I am trying to set up Ubuntu guest on windows 7 host. I want to host a test website on Ubuntu Apache 2.2 i have installed this and have tested it to see if this works on Ubuntu guest by opening firefox and browsing to localhost.
I am using 3.2.10 virtualbox.
Linux Guest is set up with 1 NIC the address it is assigned is 10.0.2.15. I have used NAT network type.
I have set up virtaulbox ipaddress 192.168.56.1 and turned off DHCP.
I have disabled windows firewall.
I need to use NAT as I only want my host machine to be able to see the webserver on guest Ubuntu.
I have created a NAT Rule using
VBoxManage modifyvm "Ubuntu" --natpf1 "webhosting,tcp,,80,10.0.2.15,80"
I have created a static route
route ADD 10.0.2.15 MASK 255.255.255.255 192.168.56.1
I have added ARP
arp -s 10.0.2.15 08-00-27-00-4c-37 (this is the mac address of virtualbox NIC)

I cant ping from either host to guest or from guest to host.
The guest does get internet access.
When I try and ping guest from host I get
Reply from 192.168.56.1: destination host unreachable
when I try and tracert to 10.0.2.15 it goes directly to my dns server and does not resolve the address locally.
I have used wireshark to view traffic of the virtualbox NIC
2 5.896531 CadmusCo_00:4c:37 Broadcast ARP Who has 10.0.2.15? Tell 192.168.56.1
I then get no page returned

Does anybody have any ideas how I can set up this type of network?
funkimunky
 
Posts: 2
Joined: 18. Oct 2010, 16:00
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: ubuntu

Re: How to set up NAT between Windows 7 host and Ubuntu guest

Postby Perryg » 18. Oct 2010, 17:07

All you need for this to work is
Code: Select all   Expand viewCollapse view
VBoxManage modifyvm "Ubuntu" --natpf1 "webhosting,tcp,,80,,80"
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to set up NAT between Windows 7 host and Ubuntu guest

Postby Sasquatch » 18. Oct 2010, 22:18

And point your browser on the Host to localhost. Administrator privileges are required to run this setup, because you register a port below 1024. If you use a port above 1024, no administrator privileges are required, but you have to enter the port number in the URL. E.g. you forward port 8080 on the Host to the port 80 in the guest, you browser to localhost:8080.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Re: How to set up NAT between Windows 7 host and Ubuntu guest

Postby Perryg » 18. Oct 2010, 22:49

Administrator privileges are required to run this setup

Not on a Windows host. Just Linux. here is the result forom issuing the command and what gets stored in the machine.xml
Code: Select all   Expand viewCollapse view
<Forwarding name="webhosting" proto="1" hostport="80" guestport="80" />
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to set up NAT between Windows 7 host and Ubuntu guest

Postby funkimunky » 19. Oct 2010, 09:54

I have tried what Perryg said
Code: Select all   Expand viewCollapse view
VBoxManage modifyvm "Ubuntu" --natpf1 "webhosting,tcp,,80,,80"

I have no routes set or anything in the arp table now.
When I browse to localhost from IE7 It just comes up with Internet Explorer cannot display the webpage
I have localhost set to 127.0.0.1 in the hosts file.
I still cant ping 10.0.2.15 (my Ubuntu guest)
I can ping the virtualmachine network interface 192.168.56.1
Is there a way to diagnose what the problem is?
funkimunky
 
Posts: 2
Joined: 18. Oct 2010, 16:00
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: ubuntu

Re: How to set up NAT between Windows 7 host and Ubuntu guest

Postby Sasquatch » 19. Oct 2010, 22:01

When the VM is running, check the output of netstat -tln[b] on the Guest and [b]netstat -an on the Host. Post the output here.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux


Return to VirtualBox on Windows Hosts

Who is online

Users browsing this forum: Google [Bot] and 58 guests