{"id":95,"date":"2021-08-16T03:07:36","date_gmt":"2021-08-16T03:07:36","guid":{"rendered":"http:\/\/webhostingpune.co.in\/blog\/?p=95"},"modified":"2021-08-16T03:07:38","modified_gmt":"2021-08-16T03:07:38","slug":"how-to-find-if-a-network-port-is-open","status":"publish","type":"post","link":"https:\/\/webhostingpune.co.in\/blog\/how-to-find-if-a-network-port-is-open\/","title":{"rendered":"How to find if a network port is open ?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><em>Using lsof to find open ports<\/em><\/strong>:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">lsof -i:22&nbsp;## see a specific port such as 22 ##<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">lsof -i -P -n | grep LISTEN<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can run any one of the above commands<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"982\" height=\"539\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen.png\" alt=\"\" class=\"wp-image-97\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen.png 982w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen-300x165.png 300w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen-768x422.png 768w\" sizes=\"auto, (max-width: 982px) 100vw, 982px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Using netstat to see the listening processes:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run netstat command along with&nbsp;<a href=\"https:\/\/www.cyberciti.biz\/faq\/howto-use-grep-command-in-linux-unix\/\" target=\"_blank\" rel=\"noopener\">grep command<\/a>&nbsp;to filter out port in LISTEN state:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">netstat -tulpn | grep LISTEN<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>t<\/strong>&nbsp;\u2013 Show TCP<br><strong>u<\/strong>&nbsp;\u2013 Show UDP<br><strong>l<\/strong>&nbsp;\u2013 Show only listening processes (netstat can show both listening and all established connections, i.e. as a client too)<br><strong>n<\/strong>&nbsp;\u2013 Do not resolve network IP address names or port numbers<br><strong>p<\/strong>&nbsp;\u2013 Show the process name that is listening on the port<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"352\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen2-1024x352.png\" alt=\"\" class=\"wp-image-98\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen2-1024x352.png 1024w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen2-300x103.png 300w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen2-768x264.png 768w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/08\/listen2.png 1216w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>You can check port usage from Windows operating system using following command<\/strong>:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">netstat -bano | more<br>netstat -bano | grep LISTENING<br>netstat -bano | findstr \/R \/C:\u201d[LISTEING]\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We hope you\u2019ve found this useful!\u00a0<\/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 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.\u00a0 Using lsof to find open ports: lsof -i:22&nbsp;## see a specific port such as 22 ## lsof -i -P -n | grep LISTEN You can run any one of the above commands Using netstat to see the listening processes: Run netstat command along with&nbsp;grep command&nbsp;to filter out port in LISTEN state: netstat -tulpn | grep LISTEN t&nbsp;\u2013 Show TCPu&nbsp;\u2013 Show UDPl&nbsp;\u2013 Show only listening processes (netstat can show both listening and all established connections, i.e. as a client too)n&nbsp;\u2013 Do not resolve network IP address names or port numbersp&nbsp;\u2013 Show the process name that is listening on the port You can check port usage from Windows operating system using following command: netstat -bano | morenetstat -bano | grep LISTENINGnetstat -bano | findstr \/R \/C:\u201d[LISTEING]\u201d We hope you\u2019ve found this useful!\u00a0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":2,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":99,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions\/99"}],"wp:attachment":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}