I am currently at my uni and connected to uni's network. I set up a server on my PC but noone can connect from outside uni network because ports are blocked, however I have access to one of uni's servers with linux and I think I could make vpn server there and connect from my pc to uni's server and people would connect in this order Internet -> VPN on my uni's server -> My PC but the thing is that I don't know which port is open and unused so I could use it as port for the vpn and the server. How can I check which port is open for sure and if it is unused? Is it possible that this solution will work and people would connect to me like this?

  • If a port is open, then it is by definition in-use (only ports which have a program bound to them are open). I have a feeling what you meant to ask is how to check if a port is unfiltered and unused, because it sounds like the important part here is that your firewall is not blocking the port and no program is using it. – Austin Hemmelgarn Dec 3 '18 at 20:30
netstat -l

Will list ports in use if you have permissions to check. Trying is the only way to see if a port is open (not being blocked by a firewall etc), one of the many ways to try is;

nc -l $IP $PORT > test.tmp

it will wait for a connection, so then in a different terminal/screen/tmux do

echo test | nc -q 0 $IP $PORT

from outside the network.... nmap is commonly used for port scanning but unless you want to test all ports is not going to help much in this case (and you would need a service binding to all ports first).

|improve this answer|||||
  • nc -l $IP $PORT > test.tmp doesn't work or I don't know how to use it properly – Arek Żyłkowski Dec 2 '18 at 13:34
  • Did you read the manual?; linux.die.net/man/1/nc . "doesn't work" is ambiguous what did you expect to happen vs what actually happened? – user1133275 Dec 2 '18 at 16:05

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.