2

I have seen "port forwarding" associated with

  • netcat/socat,
  • ssh, and
  • configuring server inside the local LAN behind a NAT device.

Does it have different meanings in the cases? For example does "port forwarding" in the first two cases mean the same as packet/datagram forwarding?

What layer in the OSI model does each case's "port forwarding" belong to? For example, does the first case belong to the transport layer, the second to the application layer, and the last to the transport layer?

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide your own answer and accept it. – Ron Maupin Aug 6 '17 at 23:53
2

In the first two, the term "port forwarding" really refers to tunneling. Tunneling encapsulates a layer-3 packet inside a new layer-3 packet so that the original can pass as the the encapsulating packet.

The original use for the term "port forwarding" came from NAT. NAT can use a port address on the outside IP address of a NAT router to forward traffic to a host on the inside network. This isn't tunneling since it directly translates the destination address to a different address without encapsulating it inside another packet. There is also layer-2 tunneling where layer-2 frames can be encapsulated in other layer-2 frames.

Both tunneling and NAT port forwarding happen at layer-3, but NAT port forwarding involves layer-4 because it depends on the transport protocol and the port address for that protocol. Tunneling can involve layer-4, too, but that depends on the tunneling implementation and how it is configured. The OSI layers are theoretical, and real life isn't so neat. Many things blur the lines between layers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.