-2

I read the answer in that link:

What is port forwarding and what is it used for?

And I asked myself - If "port-forwarding" is passing a specific package to a specific computer by a specific port, then why the same thing cant be achieved by binding the software to the port?

For example. Why does the next code in python:

 soc = socket.socket()
 soc.bind(('0.0.0.0', 80))
 soc.listen(1)
 client_soc, address = soc.accept()

Wouldn't be the same as doing port forwarding to port 80 to my computer on the LAN?

3
  • "Why does the next code in python:" - This portion of your question is not clear and currently not answerable.
    – Ramhound
    Feb 28, 2017 at 20:24
  • It looks like you have created a second account, which will also interfere with your ability to comment within your thread and to accept an answer. See How can one link/merge/combine/associate two accounts/users? and/or I accidentally created two accounts; how do I merge them? for guidance on how to merge your accounts.
    – DavidPostill
    Feb 28, 2017 at 22:25
  • You're mixing concepts here. Port forwarding is done at a NAT - it takes a packet in flight and uses the port number to route it to a host within the NAT based on a defined rule. Binding is on the host, it is essentially the creation of a listening socket. It needs to be in place for when the forwarded packet hits the the host after being routed through the NAT so that the packet can be accepted by the host and passed into the application layer from the networking stack.
    – MaQleod
    Feb 28, 2017 at 22:32

2 Answers 2

2

Binding a process to a port is something that happens inside a host so that the process will receive data sent to the host on that port.

Port forwarding has to do with an intermediate node in the path to get to the host. If packets have their addresses changed by by the intermediate node because of NAPT, then a host outside the intermediate node cannot directly send packets to the host on the other side of the node performing NAPT. The intermediate node must know that any traffic destined to its address with a certain port must be sent to the destination host. That is port forwarding, which is really just a way to make a permanent entry in the NAT table.

0

Wouldnt be the same as doing port forwording to port 80 to my computer on the LAN

It absolutely is not the same thing.

The code you supplied binds the port on the local machine. This action is independent of forwarding all traffic on a port to a specific client. You can bind a port on every client on your network but you can only forward the traffic on that port to a single client on the network.

Binding a port happens on the client side, but when you forward a port to a specific client, you are not necessarily binding that port on the client. The client still must have an application or service installed and configured to do that.

You must log in to answer this question.

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