0

Notebook connected to Wi-Fi, hosting Windows 10. Guest: VirtualBox VM running Ubuntu 18.04.

Configured VM adapter 1 to bridged mode ("Placa em modo bridge"). I assume that way is simpler than configuring NAT with port forwarding.

Invoking ipconfig on Windows 10 host includes the following information:

 Adaptador Ethernet VirtualBox Host-Only Network:

   Endereço IPv4. . . . . . . .  . . . . . . . : 192.168.56.1
   Máscara de Sub-rede . . . . . . . . . . . . : 255.255.255.0

Adaptador de Rede sem Fio Wi-Fi:

   Endereço IPv4. . . . . . . .  . . . . . . . : 192.168.15.5
   Máscara de Sub-rede . . . . . . . . . . . . : 255.255.255.0

Invoking ifconfig on guest includes the following information:

enp0s3: inet 192.168.15.6  netmask 255.255.255.0

lo: 
        inet 127.0.0.1  netmask 255.0.0.0

Rails running on guest with the following command:

$ rails s
(...)
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

When I try to access URL http://0.0.0.0:3000 from within guest it works OK. However, when I try from within host it does not, neither does http://192.168.56.1:3000 or anything else.

I've read up this question, but could not make it run on port 80 (sudo rails s -p 80 shows sudo: rails: command not found).

What am I missing to make accessing server from within host to work?

Piovezan
  • 162
  • 9

1 Answers1

1

Check your firewall on Windows, open Windows Defender Firewall with Advanced Security and click on Inbound Rules and create a rule that allows port 3000. You may also have to allow it though the Ubuntu firewall.

mully
  • 723
  • 4
  • 13
  • Thanks, I've added an Inbound Rule for TCP port 3000 on Windows (it wasn't necessary for the VM since the firewall is disabled by default on Ubuntu 18.04) but it did not work. If there is any special procedure involved, such as doing that with the VM shut down, please let me know. – Piovezan Sep 21 '21 at 20:45
  • No special procedure that I can think of, all I would do is restart the service (Rails) after creating the firewall rule. – mully Sep 21 '21 at 21:20
  • I've restarted the server, also added an Outbound Rule for the same port (not sure it was necessary, but come to think of it, accessing an outside server is an outbound request). Accessing `http://192.168.15.6:3000` worked, and the server logged `Started GET "/" for 192.168.15.5` (such IP addresses are a bit intriguing to me, but good thing it worked). – Piovezan Sep 22 '21 at 13:49
  • I'm glad you got it to work. – mully Sep 22 '21 at 13:54