I am trying to open a port in my Linux machine but I am having some trouble. I looked up some information about port forwarding and I found this What is port forwarding and what is it used for? and jcrowfordor's post (the long post with a picture) helped me understand it better.
But I still have some trouble opening a port. I looked up tutorials and videos and it always says:
- 1-Forward the port in the router
- 2-Download ufw
- 3-Create a rule in ufw that allows inbound traffic to that port
I did all that and it didn't work. Maybe I am doing something wrong? I still have some doubts about port forwarding so I think that clearing those doubts might help me figure out what I am doing wrong.
Also, the whole firewall configuring+router portforwarding might be unnecessary, because I have a Linux Mint VM that accepts inbound traffic to any port I bind using netcat (I use sudo nc -l portnumber). Why is that? I haven't configured anything, except for disabling the Linux Mint's firewall. If I disable the other Linux's firewall it still refuses connections.
My doubts regarding port forwarding are:
- When a computer from a network wants to communicate with another computer in that network does the packet it sends to the router count as inbound traffic? If so, in order for the destination computer to receive it I have to forward a port on the router, right?
- What if I want 2 or more computers to be able to receive connections on the same port? Do I have to forward that port in the router for all those computers?
- If yes, how does the router know to which computer it should send the inbound traffic? What happens when it comes from the network and when it comes from out of the network?