1
votes

My rails server (WEBrick 1.3.1) is set on the virtual machine (ubuntu 12.04) and use NAT. The default IP address is 10.0.2.15 with port 3000. How can I access from my host machine (win8) ?

I have tried to use port forwarding but it doesn't work.

Settings -> Network -> Port forwarding

Protocol | Host IP | Host Port | Guest IP | Guest Port

TCP         127.0.0.1     3308      10.0.2.15      3000

2
why are you using NAT mode?bridged mode is easier if you want direct connection to your virtual machine. - yogipriyo
@yogipriyo, you are not addressing the question. - Tass
@tony.0919, after setting up port forwarding did you attempt to navigate to 127.0.0.1:3308? Using your port forwarding settings I was able to access my rails application via a browser on my windows machine. - Tass
Hi @Tass, I just want to know the reason why he's using NAT. Because most of the time that I have read before, the owner post didn't know yet the best networking mode for their case. - yogipriyo
@yogipriyo, I do concur that it's the easiest setting if attempting to access a virtualmachine guest from its host. As someone who has asked a few questions on here I know how frustrating it can be when people suggest you do something else. Port forwarding using a NAT connection is a viable option which he/she wants to function properly. We need to be mindful of the person asking the question and focus on resolving his/her issue. - Tass

2 Answers

1
votes

By setting your port forwarding as you did, you are telling your host PC that when you visit 127.0.0.1 at port 3308 in your browser, you want that resolved to be your guest virtual machine's I.P. address at port 3000.

With your virtual machine's Rails server running, open a browser on your host PC and navigate to 127.0.0.1:3308.

If your browser doesn't render your guest server's web pages, I'd suspect you have a port conflict (that port 3308 may already be in use). In that case, search for ways to view what ports are currently in use on your PC. Find a port which is not in use and use that in your port forwarding's host port settings.

1
votes

If anyone faces the same problem, after port forwarding, I resolved this problem running the server binding the ip address of the virtual machine like this:

rails server -b 10.0.2.15