{"id":1666,"date":"2019-11-11T08:01:47","date_gmt":"2019-11-11T02:31:47","guid":{"rendered":"http:\/\/jaipurhosting.com\/blog\/?p=1666"},"modified":"2021-10-25T13:39:11","modified_gmt":"2021-10-25T08:09:11","slug":"ss-command-examples-to-monitor-network-connections","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/ss-command-examples-to-monitor-network-connections\/","title":{"rendered":"SS command examples to monitor network connections"},"content":{"rendered":"\n<p><strong>Description<\/strong><\/p>\n\n\n\n<p><strong>ss command<\/strong>&nbsp;is a tool that is used for displaying network socket related information on a Linux system. <\/p>\n\n\n\n<p>The tool displays more detailed information that the&nbsp;netstat command&nbsp;which is used for displaying active socket connections. <\/p>\n\n\n\n<p>We  see how the&nbsp;<strong>ss command<\/strong>&nbsp;can be used to display varied socket connection information in Linux. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Listing all Connections<\/h3>\n\n\n\n<p> The basic&nbsp;<strong>ss command<\/strong>&nbsp;without any options simply lists all the connections regardless of the state they are in <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1268\" height=\"246\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/1.jpg\" alt=\"\" class=\"wp-image-1667\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/1.jpg 1268w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/1-768x149.jpg 768w\" sizes=\"auto, (max-width: 1268px) 100vw, 1268px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Listing Listening and Non-listening Ports<\/h3>\n\n\n\n<p>You can retrieve a list of both listening and non-listening ports using the&nbsp;<code>-a<\/code>&nbsp;option as shown below. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -a<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1246\" height=\"291\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/2.jpg\" alt=\"\" class=\"wp-image-1668\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/2.jpg 1246w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/2-768x179.jpg 768w\" sizes=\"auto, (max-width: 1246px) 100vw, 1246px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3. Listing Listening Sockets<\/h3>\n\n\n\n<p>To display listening sockets only, use the&nbsp;<code>-l<\/code>&nbsp;flag as shown. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1272\" height=\"279\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/3.jpg\" alt=\"\" class=\"wp-image-1669\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/3.jpg 1272w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/3-768x168.jpg 768w\" sizes=\"auto, (max-width: 1272px) 100vw, 1272px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">4. List all TCP Connections<\/h3>\n\n\n\n<p>To display all TCP connection, use the&nbsp;<code>-t<\/code>&nbsp;option as shown. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -t<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1276\" height=\"252\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/4.jpg\" alt=\"\" class=\"wp-image-1670\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/4.jpg 1276w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/4-768x152.jpg 768w\" sizes=\"auto, (max-width: 1276px) 100vw, 1276px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">5. List all Listening TCP Connections<\/h3>\n\n\n\n<p>To have a view of all the listening TCP socket connection use the&nbsp;<code>-lt<\/code>&nbsp;combination as shown. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -lt<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1259\" height=\"339\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/5.jpg\" alt=\"\" class=\"wp-image-1671\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/5.jpg 1259w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/5-768x207.jpg 768w\" sizes=\"auto, (max-width: 1259px) 100vw, 1259px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">6. List all UDP Connections<\/h3>\n\n\n\n<p>To view all the UDP socket connections use the&nbsp;<code>-ua<\/code>&nbsp;option as shown. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -ua<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1288\" height=\"245\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/6.jpg\" alt=\"\" class=\"wp-image-1672\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/6.jpg 1288w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/6-768x146.jpg 768w\" sizes=\"auto, (max-width: 1288px) 100vw, 1288px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">7. List all Listening UDP Connections<\/h3>\n\n\n\n<p>To list listening UDP connections use the&nbsp;<code>-lu<\/code>&nbsp;option. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -lu<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1273\" height=\"264\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/7.jpg\" alt=\"\" class=\"wp-image-1673\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/7.jpg 1273w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/7-768x159.jpg 768w\" sizes=\"auto, (max-width: 1273px) 100vw, 1273px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">8. Display PID (Process IDs) of Sockets<\/h3>\n\n\n\n<p>To&nbsp;display the Process IDs&nbsp;related to socket connections, use the&nbsp;<code>-p<\/code>&nbsp;flag as shown. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -p<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1347\" height=\"196\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/8.jpg\" alt=\"\" class=\"wp-image-1674\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/8.jpg 1347w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/8-768x112.jpg 768w\" sizes=\"auto, (max-width: 1347px) 100vw, 1347px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">9. Display Summary Statistics<\/h3>\n\n\n\n<p>To list the summary statistics, use the&nbsp;<code>-s<\/code>&nbsp;option. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -s<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"218\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/9.jpg\" alt=\"\" class=\"wp-image-1675\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">10. Display IPv4 and IPv6 Socket Connections<\/h3>\n\n\n\n<p>If you are curious about the IPv4 socket connections use the&nbsp;<code>-4<\/code>&nbsp;option. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -4<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1272\" height=\"108\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10.jpg\" alt=\"\" class=\"wp-image-1676\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10.jpg 1272w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10-768x65.jpg 768w\" sizes=\"auto, (max-width: 1272px) 100vw, 1272px\" \/><\/figure>\n\n\n\n<p>To display IPv6 connections, use the&nbsp;<code>-6<\/code>&nbsp;option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -6<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1245\" height=\"192\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10.1.jpg\" alt=\"\" class=\"wp-image-1677\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10.1.jpg 1245w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/10.1-768x118.jpg 768w\" sizes=\"auto, (max-width: 1245px) 100vw, 1245px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">11. Filter Connections by Port Number<\/h3>\n\n\n\n<p><strong>ss command<\/strong>&nbsp;also lets you filter socket port number or address number. For example, to display all socket connections with a destination or source port of ssh run the command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -at '( dport = :22 or sport = :22 )'<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1273\" height=\"73\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/11.jpg\" alt=\"\" class=\"wp-image-1678\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/11.jpg 1273w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/11-768x44.jpg 768w\" sizes=\"auto, (max-width: 1273px) 100vw, 1273px\" \/><\/figure>\n\n\n\n<p> Alternatively, you can run the command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -at '( dport = :ssh or sport = :ssh )'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12. Check Man Pages for ss Command<\/h3>\n\n\n\n<p>To get more insights into the&nbsp;<strong>ss command<\/strong>&nbsp;usage, check the man pages using the command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>man ss<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1319\" height=\"323\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/12.jpg\" alt=\"\" class=\"wp-image-1679\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/12.jpg 1319w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/11\/12-768x188.jpg 768w\" sizes=\"auto, (max-width: 1319px) 100vw, 1319px\" \/><\/figure>\n\n\n\n<p>These are some of the commonly used options that are used with&nbsp;<strong>ss command<\/strong>. <\/p>\n\n\n\n<p>We hope you\u2019ve found this useful! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description ss command&nbsp;is a tool that is used for displaying network socket related information on a Linux system. The tool displays more detailed information that the&nbsp;netstat command&nbsp;which is used for displaying active socket connections. We see how the&nbsp;ss command&nbsp;can be used to display varied socket connection information in Linux. 1. Listing all Connections The basic&nbsp;ss [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1682,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1666","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-categorized"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=1666"}],"version-history":[{"count":3,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1666\/revisions"}],"predecessor-version":[{"id":1754,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1666\/revisions\/1754"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1682"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=1666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=1666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=1666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}