18

If I port forward port 80 UDP on my PC, can I access port 80 from my other laptop?

5
  • 1
    No; When you forward a port you send all traffic to a single address. If you need 2 devices to receive the data on the same port then you need to forward it to a single device that connects those 2 additional devices to the network ( say another router for instance ).
    – Ramhound
    Feb 5, 2015 at 12:21
  • 1
    Port 8080 can be used safely as alternative to 80 on the secondary system. So forward 80 to PC and 8080 to notebook if that is whats needed for your requrements.
    – Overmind
    Feb 5, 2015 at 12:32
  • You write "If I port forward port 80 UDP on my PC, can I access port 80 from my other laptop?" <--- Well obviously otherwise what's the point of port fowarding.
    – barlop
    Aug 13, 2015 at 17:44
  • AT Ramhound Really huh, ok, , So Why don't you explain how you'd do that?
    – barlop
    Aug 13, 2015 at 17:45
  • 1
    I recommend you accept VL-80's answer. His answer is very good. It answers what you actually asked-- nobody can speak to how it answers what you meant to ask.
    – David Betz
    Feb 12, 2016 at 14:10

4 Answers 4

15

You're asking two different questions here.

Can You Port Forward the Same Port # to 2 Different Internal IP Addresses?

No. Think about it. If a packet arrives to your external address and UDP port 80 (assuming you have only one external IP address), how would your router know which of the two internal IP addresses it should be forwarded to?

If you want to host two different services, you'll need a separate port for each.

If I port forward port 80 UDP on my PC, can I access port 80 from my other laptop?

Yes. Port forwarding generally only affects packets which have port 80 on your side. When someone tries to connect to you, your router will see:

  • incoming packet from other computer's random port X to your port 80
  • outgoing reply from your port 80 to other's port X

But outgoing connections (when you visit a web page elsewhere) will have it reversed from your router's perspective.

  • outgoing packet from your random port X to the other computer's (web server's) port 80
  • incoming reply from the other's port 80 to your port X

So port-forwarding won't affect those at all.

(By the way, HTTP generally runs on TCP. Only Chrome's QUIC experiments use UDP.)

3
  • Re "which of the two internal IP addresses it should be forwarded to", why not send to both server 192.168.1.100 and server 192.168.1.101?
    – Pacerier
    Feb 13, 2017 at 9:49
  • 1
    @Pacerier: What will the client do when it receives two entirely different replies? It won't automagically make two connections where a program requested only one. At best, it'll accept one reply packet and discard the other, which is useless since you can't tell it which server you wanted... unless both .100 and .101 provide exactly the same services (load balancing). At worst, the second reply will even prevent the first connection attempt from finishing (e.g. if the second server keeps receiving packets meant for the first one, it'll keep replying with TCP RSTs) Feb 13, 2017 at 11:26
  • 1
    @Pacerier: So, in the specific load balancing case (with nearly identical servers), that can be done – see VL-80's answer below for more detail. There are in fact load-balancing programs which duplicate the initial packet and use whichever server was fastest to reply. But if you wanted to host two different websites that way, it wouldn't work because the browser doesn't send the website hostname until long after the TCP connection has been made. Feb 13, 2017 at 11:30
6

Can You Port Forward the Same Port # to 2 Different Internal IP Addresses?

Yes, you can absolutely do it with UDP and to some degree with TCP.

Since UDP is connectionless stateless protocol you can listen for a particular port and once packet arrives you can copy it and send to two different internal destinations. Since there are no handshakes or state tracking all destinations will be able to receive those packets successfully. Samplicator is one of the programs that can do it for you. Note, that this is not a pure Port Forwarding per its definition.

This is possible for TCP, but with some limitations - you can listen for particular port and once packet arrives you can forward it to a particular internal host in a pool. TCP uses connections so once you forwarded an initial packet to a particular internal host it is now necessary to forward rest of the packets in this session to the same internal host.

By using this technology you can have multiple backend servers handling requests to one external destination.

If I port forward port 80 UDP on my PC, can I access port 80 from my other laptop?

This question is little bit unclear. If you forward traffic from your external address to one of the internal hosts then this fact alone does not prevent you to access same port from internal network.

Let's say you forward port 80 from A to B. In the same time C will be able to directly access port 80 on B without any problems.

     A (external IP)
     |
 ---------
 |       |
 B       C
5
  • 4
    The question is about routers. No consumer grade routers have the UDP copy / TCP load balancing features you describe, and none of this is ever called "port forwarding".
    – Jason C
    Jun 1, 2015 at 23:25
  • 4
    1) The question does not specify it must be a consumer level equipment. 2) Regardless of what you wrote the technique I described works.
    – VL-80
    Jun 2, 2015 at 13:48
  • 3
    No professional level router would have these features either, unless the package includes more than just a router. It's not port forwarding and routers don't perform these functions. The question asked about "port forwarding" and was tagged router. Think about the people who would have this same question, find it, and read your answer, and consider whether you're helping or confusing. Your terminology is all wrong anyways.
    – Jason C
    Jun 2, 2015 at 14:25
  • You write "This is possible for TCP, .......once you forwarded an initial packet to a particular internal host it is now necessary to forward rest of the packets in this session to the same internal host." <--- So how is this possible with TCP? You mention samplicator for UDP, ok.. so that copies it for UDP.. But what are you suggesting for TCP?
    – barlop
    Aug 13, 2015 at 17:41
  • 4
    This answer is good. I was about to say something similar. With UDP, this is what multicast and IGMP is all about. TCP, yes, roundrobin, failover, etc... Yes, routers can do this-- today's routers aren't the blind devices from the 90s. The question is vague enough to allow multiple readings, but this is how I read the qeustion as well.
    – David Betz
    Feb 12, 2016 at 14:09
1

You can not forward the same port to multiple IP simultaneously, I have not even seen a router/managed switch that will even let you do that without sending back a config error msg. You can set it up for multiple IPs but only one of the forwarding rules can be enable at a time. So you can disable one enable other and vice versa, but that is a waste You only need to be worried about forwarding ports if you want to access specific ports/service on LAN computer via it's external IP address. Say if you wanted to run 2 webservers on 2 of your LAN PCs and be able to access both of them all of the time, the easiest way to do this is change ports of the services, have one listen on port 80, and the other on 8080 or port you want. 99% of services will allow you to host/listen on any port you want. If you do not specify a port it will fall-back to the service default. There are other more advanced ways of doing things but this is the simplest way, and the advanced methods are not considered or called "Port Forwarding" anyone who says different needs to go back to networking school.

2
0

You can use a proxy internally like a WAP server which can determine what server should handle the request based on the host property of http headers ... also the port fordwarding needs to point to this Proxy

1
  • Port Forwarding happens in the session layer of the OSI model using the layers below - not in the application layer, so this answer is misleading Jan 31, 2023 at 17:09

You must log in to answer this question.

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