Mobile app version of vmapp.org
Login or Join
Karen161

: Should my web server listen on its IP address, or the public IP address with port forwarding? Let's say that I have a web server running on my PC and I would like to access it from outside

@Karen161

Posted in: #IpAddress #PortForwarding #Webserver

Let's say that I have a web server running on my PC and I would like to access it from outside my LAN, I have port forwarding set up to forward traffic to port 80 to the PC's IP, (192.168.1.10).

Should the web server listen on the PC's IP or the public IP?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

3 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

When port forwarding, NAT works by editing the IP address in the IP header of the incoming packet and then passing the packet on toward its ultimate destination, while maintaining a state table so that response packets and later packets in the same data stream go to the correct place. There are a few other things going on, but that's the part that is important to understand.

Think of NAT as taking an envelope from the "in" pile, slapping a new address label on it, and putting it in the "out" pile.

Just as the mailbox must be at the address described by the now topmost address label, the server on the internal network must listen to the IP address the router edits the IP header to point to.

Hence, when setting up a web server behind NAT port forwarding, configure your web server to listen to the internal IP address that the packets are being forwarded to.

10% popularity Vote Up Vote Down


 

@Correia994

A web server such as Apache, Nginx, Node, etc, listens on a port or ports, and a public IP. The internal IP of the PC is irrelevant except for setting routes from the public facing router/switch/modem/device. The public facing device has the public IP attached to it. Services that need to run under that IP can be forwarded to internal "local" IP(s) via ports. The server understands how to use the public IP when it needs to.

So that being said, 192.168.1.10 falls into what is known as the reserved IP address range. Most of these types of addresses are used within an intranet/LAN, and because of that will never be accessible from the outside world (internet). Unless your server is designed to run inside this LAN, or you have masked with a host file, use the public IP for all schemas.

10% popularity Vote Up Vote Down


 

@Smith883

It should listen on the IP address assigned to the PC on the LAN. When you're behind a router at home, the PC has no idea of outside world IP numbers.

Remember that you are port forwarding, not IP forwarding. Your router is using NAT (Network Address Translation) and assigning your PC its own IP, unrelated to the outside world.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme