{"id":97,"date":"2020-05-14T14:00:57","date_gmt":"2020-05-14T14:00:57","guid":{"rendered":"https:\/\/webhostingnoida.in\/blog\/?p=97"},"modified":"2021-06-28T03:09:49","modified_gmt":"2021-06-28T03:09:49","slug":"how-to-find-if-a-network-port-is-open-or-not","status":"publish","type":"post","link":"https:\/\/webhostingnoida.in\/blog\/how-to-find-if-a-network-port-is-open-or-not\/","title":{"rendered":"How to find if a network port is open or not?"},"content":{"rendered":"<p>A TCP\/IP network connection may be either blocked, dropped, open, or filtered. These actions are generally controlled by the IPtables firewall the system uses and is independent of any process or program that may be listening on a network port. Beyond the firewall, a program or process (a server or daemon) may be listening on a port or not listening. This can be checked using the netstat programs. Checking to see if a port is open, blocked, dropped, or filtered at the firewall is not simple. There are two ways to do this:<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/webhostingnoida.in\/blog\/how-to-find-if-a-network-port-is-open-or-not\/#1using_lsof_to_find_open_ports\" >1.using lsof to find open ports<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/webhostingnoida.in\/blog\/how-to-find-if-a-network-port-is-open-or-not\/#2Using_netstat_to_see_the_listening_processes\" >2.Using netstat to see the listening processes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/webhostingnoida.in\/blog\/how-to-find-if-a-network-port-is-open-or-not\/#3You_can_check_port_usage_from_Windows_operating_system_using_following_command\" >3.You can check port usage from Windows operating system using following command<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"1using_lsof_to_find_open_ports\"><\/span><strong>1.using lsof to find open ports<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>lsof -i:22 <span class=\"amp-wp-981e973\" data-amp-original-style=\"color: rgb(0, 153, 0);\">## see a specific port such as 22 ##<\/span><\/p>\n<p>lsof -i -P -n | grep LISTEN<\/p>\n<p>You can run any one of the above commands<\/p>\n<h1><span class=\"ez-toc-section\" id=\"2Using_netstat_to_see_the_listening_processes\"><\/span>2.Using netstat to see the listening processes<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Run netstat command along with\u00a0<a title=\"See Linux\/Unix grep command examples for more info\" href=\"https:\/\/www.cyberciti.biz\/faq\/howto-use-grep-command-in-linux-unix\/\" target=\"_blank\" rel=\"noopener\">grep command<\/a>\u00a0to filter out port in LISTEN state:<\/p>\n<p>netstat -tulpn | grep LISTEN<\/p>\n<p><strong>t<\/strong>\u00a0\u2013 Show TCP<br \/>\n<strong>u<\/strong>\u00a0\u2013 Show UDP<br \/>\n<strong>l<\/strong>\u00a0\u2013 Show only listening processes (netstat can show both listening and all established connections, i.e. as a client too)<br \/>\n<strong>n<\/strong>\u00a0\u2013 Do not resolve network IP address names or port numbers<br \/>\n<strong>p<\/strong>\u00a0\u2013 Show the process name that is listening on the port<\/p>\n<h1><span class=\"ez-toc-section\" id=\"3You_can_check_port_usage_from_Windows_operating_system_using_following_command\"><\/span><strong>3.You can check port usage from Windows operating system using following command<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>netstat -bano | more<br \/>\nnetstat -bano | grep LISTENING<br \/>\nnetstat -bano | findstr \/R \/C:&#8221;[LISTEING]&#8221;<\/p>\n<p>This blog can help you in finding whether port number is open or not. Hope you like this blog<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A TCP\/IP network connection may be either blocked, dropped, open, or filtered. These actions are generally controlled by the IPtables firewall the system uses and is independent of any process or program that may be listening on a network port. Beyond the firewall, a program or process (a server or daemon) may be listening on<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-linux-networking"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":1,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/97\/revisions\/98"}],"wp:attachment":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}