{"id":11339,"date":"2019-03-13T04:10:49","date_gmt":"2019-03-13T04:10:49","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11339"},"modified":"2019-03-13T04:10:49","modified_gmt":"2019-03-13T04:10:49","slug":"how-to-check-remote-ports-are-reachable-using-nc-command","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/13\/how-to-check-remote-ports-are-reachable-using-nc-command\/","title":{"rendered":"How to Check Remote Ports are Reachable Using \u2018nc\u2019 Command"},"content":{"rendered":"<p>A\u00a0<strong>port<\/strong>\u00a0is a logical entity which acts as a endpoint of communication associated with an application or process on an Linux operating system. It is useful to know which ports are open and running services on a target machine before using them.<\/p>\n<p>We can easily\u00a0<a href=\"https:\/\/www.tecmint.com\/find-open-ports-in-linux\/\" target=\"_blank\" rel=\"noopener\">list open ports in Linux<\/a>\u00a0on a local machine using the\u00a0<a href=\"https:\/\/www.tecmint.com\/20-netstat-commands-for-linux-network-management\/\" target=\"_blank\" rel=\"noopener\">netstat<\/a>\u00a0or several other Linux commands such\u00a0<a href=\"https:\/\/www.tecmint.com\/nmap-command-examples\/\" target=\"_blank\" rel=\"noopener\">NMAP<\/a>.<\/p>\n<p>In this guide, we will show you how to determine if ports on a remote host are reachable\/open using simple\u00a0<strong>netcat<\/strong>\u00a0(in short\u00a0<strong>nc<\/strong>) command.<\/p>\n<p><strong>netcat<\/strong>\u00a0(or\u00a0<strong>nc<\/strong>\u00a0in short) is a powerful and easy-to-use utility that can be employed for just about anything in Linux in relation to TCP, UDP, or UNIX-domain sockets.<\/p>\n<pre># yum install nc                  [On CentOS\/RHEL]\r\n# dnf install nc                  [On Fedora 22+]\r\n$ sudo apt-get install netcat     [On Debian\/Ubuntu]<\/pre>\n<p>We can use it to: open TCP connections, listen on arbitrary TCP and UDP ports, send UDP packets, do port scanning under both IPv4 and IPv6 and beyond.<\/p>\n<p>Using\u00a0<strong>netcat<\/strong>, you can check if a single or multiple or a range of open ports as follows. The command below will help us see if the port\u00a0<strong>22<\/strong>\u00a0is open on the host\u00a0<strong>192.168.56.10<\/strong>:<\/p>\n<pre>$ nc -zv 192.168.1.15 22\r\n<\/pre>\n<p>In the command above, the flag:<\/p>\n<ol>\n<li><code>-z<\/code>\u00a0\u2013 sets nc to simply scan for listening daemons, without actually sending any data to them.<\/li>\n<li><code>-v<\/code>\u00a0\u2013 enables verbose mode.<\/li>\n<\/ol>\n<p>The next command will check if ports\u00a0<strong>80<\/strong>,\u00a0<strong>22<\/strong>\u00a0and\u00a0<strong>21<\/strong>\u00a0are open on the remote host\u00a0<strong>192.168.5.10<\/strong>\u00a0(we can use the hostname as well):<br \/>\nnc -zv 192.168.56.10 80 22 21<\/p>\n<p>It is also possible to specify a range of ports to be scanned:\u2019<\/p>\n<pre>$ nc -zv 192.168.56.10 20-80\r\n<\/pre>\n<p>For more examples and usage of\u00a0<strong>netcat<\/strong>\u00a0command, read through our articles as follows.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/transfer-files-between-two-linux-machines\/\" target=\"_blank\" rel=\"noopener\">Transfer Files Between Linux Servers Using netcat Command<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-network-configuration-and-troubleshooting-commands\/\" target=\"_blank\" rel=\"noopener\">Linux Network Configuration and Troubleshooting Commands<\/a><\/li>\n<\/ol>\n<p>That\u2019s all. In this article, we explained how to check if ports on a remote host are reachable\/open using simple netcat commands.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/check-remote-port-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A\u00a0port\u00a0is a logical entity which acts as a endpoint of communication associated with an application or process on an Linux operating system. It is useful to know which ports are open and running services on a target machine before using them. We can easily\u00a0list open ports in Linux\u00a0on a local machine using the\u00a0netstat\u00a0or several other &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/13\/how-to-check-remote-ports-are-reachable-using-nc-command\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Check Remote Ports are Reachable Using \u2018nc\u2019 Command&#8221;<\/span><\/a><\/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-11339","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11339"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11339\/revisions"}],"predecessor-version":[{"id":11340,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11339\/revisions\/11340"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}