How to set up VM to be accessible from the Internet

Discussions related to using VirtualBox on Linux hosts.
Post Reply
alexismya2017
Posts: 4
Joined: 15. Mar 2017, 18:55

How to set up VM to be accessible from the Internet

Post by alexismya2017 »

I need to know how to set up my VirtualBox so it can be seen on the Internet. Right now I have it set up for NAT.

I am using Gophish for my clients. They are remote. I need to have a route for my employees to be able to reach my VM from their locations in other states. Since I have Gophish set up on my machine in Virginia, I have to have a way for my employees to connect to my VM from their locations in other states. How do I do this?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to set up VM to be accessible from the Internet

Post by socratis »

Either use port-forwarding in the NAT configuration, or you change the network mode to Bridged and make it part of the network, like another computer. Of course your router has to be setup to forward traffic to the Gophish port, to the VM.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
alexismya2017
Posts: 4
Joined: 15. Mar 2017, 18:55

Re: How to set up VM to be accessible from the Internet

Post by alexismya2017 »

Thank you for your reply. I am learning this all on my own and if given the exact instructions on how to do this I can get it done. So, you said:
"Of course your router has to be setup to forward traffic to the Gophish port, to the VM."

How do I set up the port forwarding in VM and then what do I do to the router? Detailed instructions will help me. Thank you!
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to set up VM to be accessible from the Internet

Post by socratis »

I can point you to the basics, not specifics. And that as far as VirtualBox is concerned. After that you'll need to do some reading on basic network concepts. Or actually before that.

In VirtualBox the way there are two ways that you can connect to the Internet. The first is NAT:
  • 
    ----------         ----------       ----------
    |   VM   |-- NAT --|  Host  |-------| Router |----- Internet
    ----------         ----------       ----------
    
You host with the help of VirtualBox translates the calls from the VM to access the Internet. It gets an address of 10.0.2.15, unless you manually change it (don't do it).

If you want to be accessed from the internet, then you have to set some port forwarding rules to your Router to forward any traffic on a specific port to the Host, and then configure the properties of the NAT network to forward the traffic to the VM. Example at the end.

The second mode is Bridged:
  • 
    ----------         ----------
    |  Host  |---------| Router |----- Internet
    ----------         ----------
                           |
    ----------             |
    |   VM   |-- Bridged --|
    ----------
Your VM is connected to the Router just like your host. It gets an IP from the Router and acts as another computer on the local network. If you want to be accessed from the internet, then you have to set some port forwarding rules to your Router to forward any traffic on a specific port to the VM.


Example
Say you have a webserver running on your VM. You want to access that VM from somewhere in the internet. You try:
    http://<YourRoutersPublicIP>:<Port>
That request must be forwarded to the VM:
  • In Bridged mode you setup your router that any traffic in <Port> (80 is the default for http but it may be occupied), will be forwarded to your VM's IP (let's say 192.168.x.x, or 10.x.x.x). Done.
  • In NAT mode you setup your router that any traffic in port <Port> (80 is the default for http but it may be occupied), will be forwarded to your host's IP (let's say 192.168.x.x, or 10.x.x.x).
    Then in the VM Settings » Network » Advanced » Port forwarding, you set a rule that any traffic coming to <Port>, should be forwarded to the VM (10.0.2.15 by default). Done.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to set up VM to be accessible from the Internet

Post by Perryg »

It's also worth noting that not all providers allow port 80 to be used. They do this to eliminate you using a web server over your private network. You would need to talk to them to be sure unless you want to use a different port.
alexismya2017
Posts: 4
Joined: 15. Mar 2017, 18:55

Re: How to set up VM to be accessible from the Internet

Post by alexismya2017 »

Thank you!
Post Reply