How to retrieve host IP from Nat VirtualBox Guest?


Dfaure

I have a Windows 7 host that handles VirtualBox debian guests with nat. This guest is running some web services accessible from outside via port redirection.

I need to provide external access to these services via url, but I can't rely on proper dns resolution, so the host ip has to be propagated to the guest environment. How can I do this with minimal impact on the host?

Some clarifications: "External", "external access" refers to a web browser at the same level as the host, ie. They can't just rely on host addresses.

A drawing is worth a thousand words:

+--------------+  External                         
| Windows Host |  network   +---------------------+
| +----+       |            |      Web client     |
| |    |      NAT           |  +----------------+ |
| |    ------------------------> Page generated | |
| |    |       |            |  |by VM with URLs | |
| | VM |       |            |  |to host         | |
| |    |       |            |  +--------|-------+ |
| |    |      FWD           |           |         |
| |    <--------------------------------+         |
| |    |       |            +---------------------+
| +----+       |                                   
+--------------+
Gunterbert

One way to do this is the trick behind sites like whatsmyip.com . All you need is a web server in your network that will send back to the client from the IP address that received the request.

Remember that since you are using NAT, the server will see the address of the NAT router (in this case the VM host) as the original address.

To do this, you can create a php-script (ie ) whatsmyip.phpin the web root of your web server , e.g.

//whatsmyip.php
<?php 
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ; 
Echo "$ip; 
?> 

and access it from your guest likehttp://webserver/whatsmyip.php

(Source: Thoughtco.com )

Now you just need to evaluate that answer in the service

Related


How do I SSH to a VirtualBox guest from outside the host?

Jordan I have an Ubuntu VM running on my Windows 7 computer. How can I set it up so that the web server can be accessed from outside via SSH? I found some steps ( setting up SSH access between the VirtualBox host and the guest VM ) to ssh the guest from the ho

VirtualBox: Find out host IP from NAT mode Linux guest

username I need to SSH from a guest VM (Linux/Debian 9) to a host running VirtualBox on a Windows 10 machine. Network configuration: NAT. Which Linux command can I use to find out the host's IP from the guest? betib Displays the internal IP address of the Virt

How do I SSH to a VirtualBox guest from outside the host?

Jordan I have an Ubuntu VM running on my Windows 7 computer. How can I set it up so that the web server can be accessed from outside via SSH? I found some steps ( setting up SSH access between the VirtualBox host and the guest VM ) to ssh the guest from the ho

How to copy paste from Ubuntu VirtualBox guest to Windows host?

Misha Moroshko I'm running VirtualBox 4.1.4 on a Windows 7 laptop with an Ubuntu 11.10 guest. I want to copy text from Ubuntu terminal and paste it into a file on Windows host. For some reason this doesn't work. Any ideas? Soekarno Start your VM, then install

How to access Virtualbox internal IP from host?

TimD1 I've been trying to learn more about security by following http://www.pentesterlab.com/bootcamp/week2/ , but I'm struggling to access the VM's internal IP localhost from the host . I can access the host's internal IP from the VM (using 10.0.2.2) and the

Access site on host from guest using VirtualBox?

Gilchaz I'm running VirtualBox on a Mac (host) and the VM used is Windows 7 (guest). VirtualBox is set up to use a NATnetwork adapter and has internet access (google, msn, etc.) fine, but I'm hosting a site on a Mac (host) so I can't access it from the VM. The

Connecting to VirtualBox guest (ubuntu) from host (osx) via NAT?

Evenk I have a VirtualBox guest (running Ubuntu) configured with NAT through my host laptop (running OSX). From what I understand, with NAT configured, I can access the guest from the host machine (without any port forwarding magic), but not from any external

SSH to Ubuntu host from Ubuntu VirtualBox guest?

Mountain X I want to SSH into my host (Kubuntu 12.04 64bit) from a VirtualBox guest running 32bit Ubuntu 12.04. The host has the latest VirtualBox from the Ubuntu repositories (4.1.12). The guest is a preconfigured VM that I downloaded from VirtualBoxImages.co

How to access Vbox guest from host when using NAT network

Lance Baines Using Fedora or Ubuntu as the host, and having firewalls turned off on both ends (vbox guest & host), what can I do to access the guest machine using the NAT interface, just like using the bridged interface? (from vbox host only!) Update : ifconfi

How to fix/set up routing from host to guest on VirtualBox?

Jonathan I am using Debian Stretch to run a Debian jessie guest. I have a guest setup using NAT and a host-only adapter. When I try to ping my guests from the host, my pings are routed to my wireless internet adapter instead of the virtual network. From ifconf

How to copy paste from Ubuntu VirtualBox guest to Windows host?

Misha Moroshko I'm running VirtualBox 4.1.4 on a Windows 7 laptop with an Ubuntu 11.10 guest. I want to copy text from Ubuntu terminal and paste it into a file on Windows host. For some reason this doesn't work. Any ideas? Soekarno Start your VM, then install

How to provide internet access to HOST from GUEST in VirtualBox

Chitholian I'm running a Windows 7 guest OS on a Fedora Linux host (in VirtualBox-6). I have a GSM USB modem. I can connect the modem to the host and have access to both the host and the guest, but cannot make USSD or VOICE calls; because the linux driver (and

How to access Apache from host (on VirtualBox guest)?

urok93 I have Apache installed on an Ubuntu VM. When I go into the client machine and load Firefox, I can see that Apache is running fine when I browse to localhost. I want to access the same page through the host. I tried using the guest's IP address, but not

VirtualBox - how to pass modem from ubuntu host to windows guest

Carlos Castellanos Is it possible to pass a USB modem that is not recognized by the host Ubuntu 15.04 to a Windows guest? , I have Windows drivers and I want to use dialup while keeping my Ubuntu host. what should I do? Can any other virtualization software he

How do I SSH to a VirtualBox guest from outside the host?

Jordan I have an Ubuntu VM running on my Windows 7 computer. How can I set it up so that the web server can be accessed from outside via SSH? I found some steps ( setting up SSH access between the VirtualBox host and the guest VM ) to ssh the guest from the ho

How to copy paste from Ubuntu VirtualBox guest to Windows host?

Misha Moroshko I'm running VirtualBox 4.1.4 on a Windows 7 laptop with an Ubuntu 11.10 guest. I want to copy text from Ubuntu terminal and paste it into a file on Windows host. For some reason this doesn't work. Any ideas? Soekarno Start your VM, then install

Connecting to VirtualBox guest (ubuntu) from host (osx) via NAT?

Evenk I have a VirtualBox guest (running Ubuntu) configured with NAT through my host laptop (running OSX). From what I understand, with NAT configured, I can access the guest from the host machine (without any port forwarding magic), but not from any external

How to access Virtualbox internal IP from host?

TimD1 I've been trying to learn more about security by following http://www.pentesterlab.com/bootcamp/week2/ , but I'm struggling to access the VM's internal IP localhost from the host . I can access the host's internal IP from the VM (using 10.0.2.2) and the

How to access Vbox guest from host when using NAT network

Lance Baines Using Fedora or Ubuntu as the host, and having firewalls turned off on both ends (vbox guest & host), what can I do to access the guest machine using the NAT interface, just like using the bridged interface? (from vbox host only!) Update : ifconfi

How to retrieve host IP from Nat VirtualBox Guest?

Dfaure I have a Windows 7 host that handles VirtualBox debian guests with nat. This guest is running some web services accessible from outside via port redirection. I need to provide external access to these services via url, but I can't rely on proper dns res

How to fix/set up routing from host to guest on VirtualBox?

Jonathan I am using Debian Stretch to run a Debian jessie guest. I have a guest setup using NAT and a host-only adapter. When I try to ping my guests from the host, my pings are routed to my wireless internet adapter instead of the virtual network. From ifconf

VirtualBox - how to pass modem from ubuntu host to windows guest

Carlos Castellanos Is it possible to pass a USB modem that is not recognized by the host Ubuntu 15.04 to a Windows guest? , I have Windows drivers and I want to use dialup while keeping my Ubuntu host. what should I do? Can any other virtualization software he

How to access Apache from host (on VirtualBox guest)?

urok93 I have Apache installed on an Ubuntu VM. When I go into the client machine and load Firefox, I can see that Apache is running fine when I browse to localhost. I want to access the same page through the host. I tried using the guest's IP address, but not

VirtualBox: Find out host IP from NAT mode Linux guest

username I need to SSH from a guest VM (Linux/Debian 9) to a host running VirtualBox on a Windows 10 machine. Network configuration: NAT. Which Linux command can I use to find out the host's IP from the guest? betib Displays the internal IP address of the Virt