{"id":199,"date":"2009-04-29T22:31:34","date_gmt":"2009-04-30T03:31:34","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=199"},"modified":"2019-09-04T19:57:41","modified_gmt":"2019-09-05T00:57:41","slug":"how-to-check-for-open-ports-on-your-server-using-netstat","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=199","title":{"rendered":"How to check for open ports on your server using Netstat."},"content":{"rendered":"<p>Netstat is a really handy tool that comes packaged with Microsoft Windows, Linux and Unix.  There is a version for each type of operating system, the command syntax may differ but the result is the same.<\/p>\n<div style=\"float: right;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\ngoogle_ad_format = \"468x60_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p>There are many a times when I need to find out what ports are open and listening on my server.  It could be after I had installed a new software that listens on a TCP port, for example SMTP is tcp port 25.   I then need to confirm if the software is actually listening on that port by executing the Netstat command from the command line. <\/p>\n<p>Here is an example of the Linux version of Netstat command with the output redirected to a file.  You can then read the file at your leisure.<br \/>\n<strong><br \/>\n$ netstat -ta > results.file<\/strong><\/p>\n<p>The options <strong>-t, -u -w<\/strong> and <strong>-x<\/strong> shows active TCP, UDP, RAW, or UNIX socket connections respectively.  The <strong>-a<\/strong> flag displays the listening socket or ports that are waiting for a connection.  The output is then stored in a file called results.file.<\/p>\n<p>You can view the contents of results.file by issuing the cat command.<\/p>\n<p><strong>$ cat results.file<\/strong><\/p>\n<p>Active Internet connections (servers and established)<br \/>\nProto Recv-Q Send-Q Local Address     Foreign Address    State<br \/>\ntcp        0      0           *:32769                *:*                         LISTEN<br \/>\ntcp        0      0           *:mysql                *:*                         LISTEN<br \/>\ntcp        0      0           *:netbios-ssn       *:*                         LISTEN<br \/>\ntcp        0      0           *:sunrpc               *:*                         LISTEN<br \/>\ntcp        0      0           10.0.0.10:http      194.246.124.67:47616  SYN_RECV<br \/>\ntcp        0      0           *:ftp                      *:*                       LISTEN<br \/>\ntcp        0      0           *:smtp                  *:*                       LISTEN<br \/>\ntcp        0      0           *:microsoft-ds      *:*                         LISTEN<br \/>\ntcp        0      0            10.0.0.10:smtp    segment-124-30.sify.n:62876 ESTABLISHED<br \/>\ntcp        0      0            10.0.0.10:smtp    187-26-172-177.3g.clar:3258 ESTABLISHED<br \/>\ntcp        0      0           *:imaps                *:*                         LISTEN<br \/>\ntcp        0      0          *:pop3s                 *:*                         LISTEN<br \/>\ntcp        0      0          *:pop3                  *:*                         LISTEN<br \/>\ntcp        0      0          *:imap                  *:*                         LISTEN<br \/>\ntcp        0      0           *:http                   *:*                         LISTEN<br \/>\ntcp        0      0           *:ssh                    *:*                         LISTEN<br \/>\ntcp        0      0           *:https                 *:*                         LISTEN<br \/>\ntcp        0      0            ::ffff:10.0.0.10:http       crawl-66-249-73-83.go:50152 ESTABLISHED<br \/>\ntcp        0      0           ::ffff:10.0.0.10:http       p3251-ipad313sasajima.:1887 ESTABLISHED<br \/>\ntcp        0      0           ::ffff:10.0.0.10:http       p3251-ipad313sasajima.:1888 ESTABLISHED<br \/>\ntcp        0  12920      ::ffff:10.0.0.10:http       ::ffff:213.163.65.177:44628 ESTABLISHED<br \/>\ntcp        0      0 ::ffff:10.0.0.10:http       DS28589.clientshostna:39831 TIME_WAIT<br \/>\ntcp        0      0 ::ffff:10.0.0.10:http       llf520046.crawl.yahoo:60010 TIME_WAIT   <\/p>\n<p>Below is the help file for the Windows version of Netstat.<\/p>\n<p>C:\\>netstat ?<\/p>\n<p>Displays protocol statistics and current TCP\/IP network connections.<\/p>\n<p>NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]<\/p>\n<p>  -a            Displays all connections and listening ports.<br \/>\n  -b            Displays the executable involved in creating each connection or<br \/>\n                listening port. In some cases well-known executables host<br \/>\n                multiple independent components, and in these cases the<br \/>\n                sequence of components involved in creating the connection<br \/>\n                or listening port is displayed. In this case the executable<br \/>\n                name is in [] at the bottom, on top is the component it called,<br \/>\n                and so forth until TCP\/IP was reached. Note that this option<br \/>\n                can be time-consuming and will fail unless you have sufficient<br \/>\n                permissions.<br \/>\n  -e            Displays Ethernet statistics. This may be combined with the -s<br \/>\n                option.<br \/>\n  -n            Displays addresses and port numbers in numerical form.<br \/>\n  -o            Displays the owning process ID associated with each connection.<br \/>\n  -p proto      Shows connections for the protocol specified by proto; proto<br \/>\n                may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s<br \/>\n                option to display per-protocol statistics, proto may be any of:<br \/>\n                IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.<br \/>\n  -r            Displays the routing table.<br \/>\n  -s            Displays per-protocol statistics.  By default, statistics are<br \/>\n                shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;<br \/>\n                the -p option may be used to specify a subset of the default.<br \/>\n  -v            When used in conjunction with -b, will display sequence of<br \/>\n                components involved in creating the connection or listening<br \/>\n                port for all executables.<br \/>\n  interval      Redisplays selected statistics, pausing interval seconds<br \/>\n                between each display.  Press CTRL+C to stop redisplaying<br \/>\n                statistics.  If omitted, netstat will print the current<br \/>\n                configuration information once.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Netstat is a really handy tool that comes packaged with Microsoft Windows, Linux and Unix. There is a version for each type of operating system, the command syntax may differ but the result is the same. There are many a&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=199\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[21,55,25,35],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/199"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199"}],"version-history":[{"count":7,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":718,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions\/718"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}