Page 1 of 1

Access Debian (guest) localhost from Windows 7 (host)

Posted: 23. Mar 2015, 12:38
by ThomasMueller
Hi,

I want to access from the host (Windows 7) to guest (Debian) localhost. I can access my vhosts (172.16.2.152 laravel-dev) but not for example localhost:8000 (Laravel development server).

Code: Select all

Windows 7 IP Configuration - Host

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : local
   Link-local IPv6 Address . . . . . : fe80::39f5:9636:862f:3975%11
   IPv4 Address. . . . . . . . . . . : 172.16.1.152
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : 172.16.1.1

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::c8e2:85e4:5b14:b280%15
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Tunnel adapter isatap.local:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : local

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.{F46B47AE-DAF6-45DA-A611-A9558D2ABD4E}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Code: Select all

Debian 7.8 IP Configuration - Guest

eth0      Link encap:Ethernet  HWaddr 08:00:27:fc:d4:cd
          inet addr:172.16.2.152  Bcast:172.16.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fefc:d4cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8022 errors:0 dropped:0 overruns:0 frame:0
          TX packets:375 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:626773 (612.0 KiB)  TX bytes:39906 (38.9 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:630 (630.0 B)  TX bytes:630 (630.0 B)

Code: Select all

C:\Windows\system32>ping 172.16.2.152

Pinging 172.16.2.152 with 32 bytes of data:
Reply from 172.16.2.152: bytes=32 time<1ms TTL=64
Reply from 172.16.2.152: bytes=32 time<1ms TTL=64
Reply from 172.16.2.152: bytes=32 time<1ms TTL=64
Reply from 172.16.2.152: bytes=32 time=1ms TTL=64

Ping statistics for 172.16.2.152:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
network_settings.PNG
network_settings.PNG (45.16 KiB) Viewed 1247 times
Many Thanks!

Re: Access Debian (guest) localhost from Windows 7 (host)

Posted: 23. Mar 2015, 13:31
by scottgus1
If I understand you, you want to access something running in your guest from your host. Your guest's IP address is 172.16.2.152. You can ping your guest from your host - good - so network has ben established. You can also access the guest's server from the host using the guest's IP address, it sounds like. Also good.

Now you wish to type in "localhost:8000" on your host and get the server in the guest? According to the Windows Hosts file:

Code: Select all

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
It sounds like the term "localhost" has been used already. If it is even possible to re-direct "localhost" to point to something else than the usual, you'll probably break several things that depend on using that term in the usual way. See this Wikipedia article on "localhost" http://en.wikipedia.org/wiki/Localhost

You could put a unique name for the guest's IP address in the hosts file and use that name instead. If you want to use the same name in the guest to access the guest server from within the guest, you could use the same name in the guest's hosts file, and point that unique name to the same address localhost points to.

Re: Access Debian (guest) localhost from Windows 7 (host)

Posted: 23. Mar 2015, 15:26
by ThomasMueller
I start the Laravel development server on Debian with:

Code: Select all

php artisan serve
and i get this message:

Code: Select all

Laravel development server started on localhost:8000
I have entered in the Windows hosts file:

Code: Select all

172.16.2.152	laravel-dev
I can now access laravel-dev file system:
connect_to_guest_1.png
connect_to_guest_1.png (30.4 KiB) Viewed 1223 times
but not Port 8000 (Laravel development server):
connect_to_guest_2.png
connect_to_guest_2.png (40.01 KiB) Viewed 1223 times

Re: Access Debian (guest) localhost from Windows 7 (host)

Posted: 23. Mar 2015, 16:19
by scottgus1
I would guess that since you can get access to "laravel-dev" from within your host successfully, then your communications channel from host to guest is running and Virtualbox is doing its job correctly. So the failure of "laravel-dev:8000" would tell me to check if there's a firewall of sorts running in the guest and that particular port isn't open. Figuring how to check that would be a question for the Debian and/or larval folks.