Omar Jarkas
Omar Jarkas

Reputation: 110

Making a Virtual machine IP (private IP) address public/accessible for outside

I'm currently working on web hosting software (like simple Nginx/apache). So the code basically, when run, listens on port 8080 for incoming web traffic.

The code runs on Ubuntu Linux virtual box (so it uses a private IP). My problem is, how to connect to the private IP from an external browser.

By running ifconfig eth0 if get the private IP address the following 10.0.2.15. Since the web application is being hosted on the virtual box on port 8080. To access the webserver I need to enter in the browser 10.0.2.15:8080, however, 10.0.2.15 is a private IP address running in the virtual box that is not accessible without NAT to the external world.

I hope I made my question clear, I want to find a way to make my virtual machine that is running Linux (that has a private IP) accessible to the external world.

Thank you

Upvotes: 1

Views: 1067

Answers (1)

tyChen
tyChen

Reputation: 1494

If you want to use an specific external browser to access to the private IP, you can simply use iptables to do some specific settings.

However, if you want to access to the private IP with random external IP, it's relatively hard cause NAT is designed partly for the security of internal network (the other side is for the extension of addresses). For the most used NAPT of routers, here are four types : Full Cone NAT, Restricted NAT, Port Restricted NAT and Symmetric NAT. The difference of the four types can google easily and get the answer, so I don't want to repeat it here.

The key is that you need a P2P traversal (also named as p2p pounch hole) to make the NAT rules not effect on some specific internal IP, and it can work good for the first three types. Some mature techs like TURN/STUN/ICE can realise them, you can use them to fullfill your demand.

Upvotes: 1

Related Questions