0

I'm working on a desktop PC and I run a local website. I can open the website using my private IP address: http://192.168.0.50:8010/connect/webcontent/ (example).

The problem is I can't access the website using the public IP address: http://139.255.51.226:8010/connect/webcontent/ (example).

What I want is for my private IP (192.168.0.50) to be accessible by the public IP (139.255.51.226) and other PC as well. Please note my web server is located on a VM.

Can someone help me solve this ?

1
  • 1
    You will need to configure port forwarding on your router. Can you tell us which make/model of router you use at the moment? Commented Aug 24, 2016 at 6:50

1 Answer 1

3

You want to check a few things:

If you have multiple normal public IP addresses:

  • Assign a regular public IP address to your web server.
  • Make sure your router knows how to route to this.
  • Bind the web server to respond on this IP:8010 tuple.

This is the way the Internet was designed. Sadly, we have mostly run out of IP v4 addresses, resulting in an ugly kludge called NAT. This is almost certainly what you are using at home, so keep reading.

If you only have one public IP (e.g., 139.255.51.226) and use RFC1918 addresses behind it (e.g., 192.168.x.x) with the help of Network Address Translation (NAT), then:

  • Go to your router (probably part of your SoHo 'modem') and set up port forwarding. Tell it to forward port 8010 to 192.168.0.50:8010.
  • Try to make sure that your web server stays at this IP address. Usually, this is done by adding an entry to the reserved IPs list in the DHCP server. On SoHo 'modems', the DHCP server usually is part of the 'modem'. You can skip this, but if the IP of the server changes, you would need to redo the port forwarding rule, as well potentially forward to an unintended host should that one accidentally get the old IP. That is not much of a risk at home, but it is very bad practice.

Now, from outside your network (e.g., using a browser on a phone connected via the phone's Internet and not via Wi-Fi), try to open http://139.255.51.226:8010/connect/webcontent/

This request will be routed to your 'modem'.
The modem will see that it is for port 8010 and forward it to 192.168.0.50:8010.

Note that this will not work from inside your local network unless your modem supports something called “hairpin NAT”.

Please note my web server is located on a VM.

As long as the VM is connected to your network (e.g., using “bridging” rather than “host-only networking”), this should not matter.


As mentioned by @doezer: If your external IP changes, then you obviously need to use the new value rather than http://139.255.51.226:8010/connect/webcontent/. The easiest way around this is by not referring to an IP address but to a name. DNS is used for that. If you have a dynamic IP, then look at DynDNS.

Also, if you can use IPv6, then no port forwarding is needed at all. Just give each computer (real or VM) its own IP address.

4
  • He might also need dynamic DNS services if the public IP is.
    – Doezer
    Commented Aug 24, 2016 at 12:26
  • if the public IP is. -> 'if the public IP is dynamic? Not sure how that works in other countries or with other ISPS, but I have the idea that dynamics IPs change rarely (say once every few years).
    – Hennes
    Commented Aug 24, 2016 at 22:17
  • It depends on the ISP. In France it's common to see the IP has been modified after a few days.
    – Doezer
    Commented Aug 24, 2016 at 22:20
  • Ah, ok. Will edit it in then.
    – Hennes
    Commented Aug 24, 2016 at 22:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .