0

Scenario:

I have a port forwarded router i.e forwarded port 80 to HostA. I have another host HostB on the same network running web service on port 80. How will NAT handle that?

1
  • when forwarding ports, all the external ports you forward must be unique. The only exceptions to this are sophisticated enterprise devices like Load Balancers, which can use upper layer information to disambiguate. Commented Dec 8, 2017 at 17:35

2 Answers 2

2

It won't. That is, the router will not let you forward the same port 80 on the same external IP address to both hosts at once. (If it does, only the "first" rule will match.)

To run several web servers behind a single IP address, you'd to forward the port 80 to a reverse proxy which then does a similar thing but at HTTP level. (That is, the reverse proxy understands HTTP requests and decides based on the HTTP "Host" or TLS SNI header.) Various popular web servers (e.g. Apache, Nginx) have a reverse-proxy function, but there also are dedicated ones.

2

Wen accessing through LAN HostA will point to HostA, HostB to HostB. Ex. hosta.domain.com:80 (or by ip) hostb.domain.com:80 will respond normally.

When accessing through WAN (public internet, not local) it will respond with HostA so RouterIP:80 or hosta.domain.com will connect to HostA, while HostB simply doesn't exist or respond.

--- Assuming that HostA is listening to port 80.

If only HostB is listening to port 80 then none of them will work on WAN while only HostB will work on LAN since it's the only one listening for connections.

You must log in to answer this question.

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