How to check if port is open and unused?











up vote
0
down vote

favorite












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?










share|improve this question






















  • 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 at 20:30















up vote
0
down vote

favorite












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?










share|improve this question






















  • 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 at 20:30













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?










share|improve this question













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?







networking vpn port-forwarding






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 1 at 23:26









Arek Żyłkowski

41




41












  • 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 at 20:30


















  • 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 at 20:30
















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 at 20:30




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 at 20:30










1 Answer
1






active

oldest

votes

















up vote
1
down vote













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).






share|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 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 at 16:05











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485409%2fhow-to-check-if-port-is-open-and-unused%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













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).






share|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 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 at 16:05















up vote
1
down vote













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).






share|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 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 at 16:05













up vote
1
down vote










up vote
1
down vote









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).






share|improve this answer














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).







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 2 at 16:07

























answered Dec 1 at 23:50









user1133275

2,780515




2,780515












  • nc -l $IP $PORT > test.tmp doesn't work or I don't know how to use it properly
    – Arek Żyłkowski
    Dec 2 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 at 16:05


















  • nc -l $IP $PORT > test.tmp doesn't work or I don't know how to use it properly
    – Arek Żyłkowski
    Dec 2 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 at 16:05
















nc -l $IP $PORT > test.tmp doesn't work or I don't know how to use it properly
– Arek Żyłkowski
Dec 2 at 13:34




nc -l $IP $PORT > test.tmp doesn't work or I don't know how to use it properly
– Arek Żyłkowski
Dec 2 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 at 16:05




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 at 16:05


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485409%2fhow-to-check-if-port-is-open-and-unused%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

List directoties down one level, excluding some named directories and files

list processes belonging to a network namespace

list systemd RuntimeDirectory mounts