Search code examples
networkingip-addressportforwardingports

Why do we have to use port 8001 when Port Forwarding?


I've tried to do as much research as I can around this and I can't seem to understand one thing. For my University project we were required to do the following:

  • In VirtualBox Manager select File>Preferences. Select Network and choose NatNetwork (or the one you are using).
  • Chose the edit network icon.
  • Select Port Forwarding
  • In the dialogue box provide a name for the rule (e.g. web), leave the host IP blank, provide a host port (e.g. 8001), then enter the Guest IP as the IP address of UBUNTU#1 and Guest port as 80 for a web server (answer yes to any Firewall questions).
  • Start a simple web server on UBUNTU#1 by using the following command in the terminal window:

    sudo python2 -m SimpleHTTPServer 80
    
  • Start Wireshark on the private network.
  • Start a web browser on the host computer and enter x.x.x.x:8001, where x.x.x.x is the IP address of your host computer.

Now we need to explain why do we use this address and port number?

My understanding is that the IP address being used belongs to the router/client on the network we want to make accessible to computers on the internet.

What I don't understand is why we have to use the port 8001?

I've seen that port 8001 is used for diagnostics, I have also seen 8001 is used as it is an available port. But how can it be available if it is being used by someone else.


Solution

  • You can use any port you like as long as both server and client agree on the port number.

    Commonly, most services use a "well known" port to make it easy for someone else to connect to them (e.g. TCP 25 for SMTP, UDP 53 for DNS, TCP 80 for WWW, ...).