• 2
name Punditsdkoslkdosdkoskdo

Connect to the host machine from a VirtualBox visitor OS?

I'd essentially like to access my host computer from the guest in VirtualBox. Is there an IP address given for my host which I can use from the guest? Are there extra steps required to set this up? I'd like to access my host's Apache, FTP, and SSH services.

SuperUser contributor DavidPostill has the answer for us:

What is the Difference Between and

  • is the loopback address (also known as localhost).
  • is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a ‘no particular address’ place holder).

In the context of a route entry, it usually means the default route.

In the context of servers, means all IPv4 addresses on the local machine. If a host has two IP addresses, and, and a server running on the host listens on, it will be reachable at both of those IPs.

What is the IP Address is the loopback Internet protocol (IP) address also referred to as the localhost. The address is used to establish an IP connection to the same machine or computer being used by the end-user.

The same convention is defined for computers that support IPv6 addressing using the connotation of ::1. Establishing a connection using the address is the most common practice; however, using any IP address in the range of 127…* will function in the same or a similar manner. The loopback construct gives a computer or device capable of networking the capability to validate or establish the IP stack on the machine.

Source: – What Are its Uses and Why is it Important?

Special Addresses

The class A network number 127 is assigned the loopback function, that is, a datagram sent by a higher level protocol to a network 127 address should loop back inside the host. No datagram sent to a network 127 address should ever appear on any network anywhere.

Source: Network Numbers

If it is Whole Class A, What is the Point of Other Arbitrary Values for the Last Three Octets?

The purpose of the loopback range is testing of the TCP/IP protocol implementation on a host. Since the lower layers are short-circuited, sending to a loopback address allows the higher layers (IP and above) to be effectively tested without the chance of problems at the lower layers manifesting themselves. is the address most commonly used for testing purposes.

Source: IP Reserved, Loopback and Private Addresses

For more information see the Ask Ubuntu question: What is the Loopback Device and How do I Use it?

What is the IP Address is a valid address syntax. So it should parse as valid wherever an IP address in traditional dotted-decimal notation is expected. Once parsed and converted to workable numeric form, then its value determines what happens next.

The all-zero value does have a special meaning. So it is valid, but has a meaning that may not be appropriate (and thus treated as not valid) for particular circumstances. It is basically the ‘no particular address’ placeholder. For things like address binding of network connections, the result can be to assign an appropriate interface address to the connection. If you are using it to configure an interface, it can instead remove an address from the interface. It depends on the context of use to determine what ‘no particular address’ really does.

In the context of a route entry, it usually means the default route. That happens as a result more of the address mask, which selects the bits to compare. A mask of selects no bits, so the comparison will always succeed. So when such a route is configured, there is always somewhere for packets to go (if configured with a valid destination).

In some cases, merely ‘0’ will also work and have the same effect. But this is not guaranteed. The form is the standard way to say ‘no particular address’ (in IPv6 that is ::0 or just ::).

Source: What is the Meaning of the IP Address

In Internet Protocol version 4, the address is a non-routable meta-address used to designate an invalid, unknown, or non applicable target. To give a special meaning to an otherwise invalid piece of data is an application of in-band signaling.

In the context of servers, means all IPv4 addresses on the local machine. If a host has two IP addresses, and, and a server running on the host listens on, it will be reachable at both of those IPs (Note: This particular text is repeated from above as part of the overall answer).

In the context of routing, usually means the default route, i.e. the route which leads to ‘the rest of’ the Internet instead of somewhere on the local network.

Uses Include:

  • The address a host claims as its own when it has not yet been assigned an address. Such as when sending the initial DHCPDISCOVER packet when using DHCP.
  • The address a host assigns to itself when an address request via DHCP has failed, provided the host’s IP stack supports this. This usage has been replaced with the APIPA mechanism in modern operating systems.
  • A way to specify any IPv4-host at all. It is used in this way when specifying a default route.
  • A way to explicitly specify that the target is unavailable. Source: – What Are its Uses and Why is it Important?
  • A way to specify any IPv4 address at all. It is used in this way when configuring servers (i.e. when binding listening sockets). This is known to TCP programmers as INADDR_ANY. [bind(2) binds to addresses, not interfaces.]

In IPv6, the all-zeros-address is written as ::

Source: [Wikipedia]

DHCP Discovery/Request

When a client boots up for the first time, it is said to be in the initializing state, and transmits a DHCPDISCOVER message on its local physical subnet over User Datagram Protocol (UDP) port 67 (BootP server). Since the client has no way of knowing the subnet to which it belongs, the DHCPDISCOVER is an all subnets broadcast (destination IP address of, with a source IP address of The source IP address is since the client does not have a configured IP address.

If a DHCP server exists on this local subnet and is configured and operating correctly, the DHCP server will hear the broadcast and respond with a DHCPOFFER message. If a DHCP server does not exist on the local subnet, there must be a DHCP/BootP Relay Agent on this local subnet to forward the DHCPDISCOVER message to a subnet that contains a DHCP server.

This relay agent can either be a dedicated host (Microsoft Windows Server, for example) or a router (a Cisco router configured with interface level IP helper statements, for example).

After the client receives a DHCPOFFER, it responds with a DHCPREQUEST message, indicating its intent to accept the parameters in the DHCPOFFER, and moves into the requesting state. The client may receive multiple DHCPOFFER messages, one from each DHCP server that received the original DHCPDISCOVER message. The client chooses one DHCPOFFER and responds to that DHCP server only, implicitly declining all other DHCPOFFER messages. The client identifies the selected server by populating the Server Identifier option field with the DHCP server’s IP address.

The DHCPREQUEST is also a broadcast, so all DHCP servers that sent a DHCPOFFER will see the DHCPREQUEST, and each will know whether its DHCPOFFER was accepted or declined. Any additional configuration options that the client requires will be included in the options field of the DHCPREQUEST message. Even though the client has been offered an IP address, it will send the DHCPREQUEST message with a source IP address of At this time, the client has not yet received verification that it is clear to use the IP address.

  • 0
Reply Report

If you need other machines in your physical network to be able to reach your VM (or if the VM needs Internet access), use bridged networking. Otherwise, stick to host-only networking.

  1. Stop your VM and open its settings in the VirtualBox (OSE) Manager
  2. Go to the Network tab
  3. Select the network mode at your choice (bridged networking or host-only) (in the below example, I'm using host-only)

    If you want to use bridged networking, you've to select the right network adapter at Name. For wired connections, you'd select something named like eth0. Wireless connections are usually named wlan0 (the numbers may vary)

  4. Save the settings
  5. Start the Ubuntu VM
  6. When up, you can gather the IP address by running:

    ifconfig | grep addr

    In the below output, is the IP address that can be used in your Win7 host system to access your VM:

    eth0  Link encap:Ethernet  HWaddr 08:00:27:70:27:fe  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe7b:25fe/64 Scope:Link
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
  7. In your windows host system, edit C:WindowsSystem32driversetchosts as administrator and add a line:

    If you've a Ubuntu host system, edit /etc/hosts using sudo nano /etc/hosts

  8. Profit!
  • 1
Reply Report

This answer is about pretty much an guest OS setup in VirtualBox; you just need to use the network gateway address on the guest OS to connect to the host OS from a guest OS.

In the default Vagrant setup, you should be able to reach your host through the default gateway.

On Windows based guests, you can easily determine this IP address by running the command:


It should dump out something like this:

Windows IP Configuration

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . :
        Subnet Mask . . . . . . . . . . . :
        Default Gateway . . . . . . . . . :

In this example, the guest can reach the host machine

On Unix/Linux based guests, use the command:

netstat -rn

It should dump out something like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface   U         0 0          0 wlan0     U         0 0          0 wlan0         UG        0 0          0 wlan0

In this example, the guest can reach the host machine

  • 1
Reply Report

Related Questions

Trending Tags