{"id":5492,"date":"2026-10-31T10:50:23","date_gmt":"2026-10-31T10:50:23","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=5492"},"modified":"2026-10-31T10:50:24","modified_gmt":"2026-10-31T10:50:24","slug":"netcat-nc-simple-examples","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=5492","title":{"rendered":"Netcat (NC) Simple Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Netcat (nc) is a simple, but very useful tool to perform connection tests and scans on your network. Its helpful to quickly check if a port is open (and listening) on a remote machine and that firewall change you made is working as expected.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here i&#8217;ll provide some simple examples for you to try.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check HTTP or HTTPS Listening<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -v www.bbc.co.uk 80<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -v www.bbc.co.uk 443<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Of course you can choose another port number and try checking that if you so wish.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Scan a Range of IP Addresses<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can also scan a range of IP addresses with something like the below, lets see what are open on this host on my network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;-z&#8221; mode, is zero-I\/O mode, meaning it will scan the port, but not any data.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -zv 192.168.10.5 80-81<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Or let&#8217;s say you think you know which ports a host is listening on and want to confirm, you can just write a list of ports (rather than a range):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -zv 192.168.10.5 22 80 443<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ nc -zv 192.168.10.5 22 80 443\nConnection to 192.168.10.5 22 port &#91;tcp\/ssh] succeeded!\nConnection to 192.168.10.5 80 port &#91;tcp\/http] succeeded!\nConnection to 192.168.10.5 443 port &#91;tcp\/https] succeeded!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Chat Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">What about a cheeky chat server, so you can send messages from one machine to another<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the server run (choosing an unused port of course):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ nc -l 1800<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then on the client run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ nc 192.168.10.5 1800<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then whatever you type will appear on the remote machine!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Some Help<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To see some help about using the command just run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -help<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OK, this has been a quick introduction, but netcat can do much more, try playing around with it, you never know when it will help you out!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Netcat (nc) is a simple, but very useful tool to perform connection tests and scans on your network. Its helpful to quickly check if a port is open (and listening) on a remote machine and that firewall change you made is working as expected. Here i&#8217;ll provide some simple examples for you to try. Check &#8230; <a title=\"Netcat (NC) Simple Examples\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=5492\" aria-label=\"Read more about Netcat (NC) Simple Examples\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":4282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,20],"tags":[],"class_list":["post-5492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-random"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5492"}],"version-history":[{"count":2,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5492\/revisions"}],"predecessor-version":[{"id":5494,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5492\/revisions\/5494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/media\/4282"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}