{"id":2121,"date":"2015-04-06T19:07:23","date_gmt":"2015-04-06T19:07:23","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2121"},"modified":"2015-04-06T19:07:23","modified_gmt":"2015-04-06T19:07:23","slug":"netstat-commands-for-ddos-checking","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/04\/06\/netstat-commands-for-ddos-checking\/","title":{"rendered":"Netstat Commands for DDoS Checking"},"content":{"rendered":"<p>Useful commands to check if a server is getting ddos&#8217;d<\/p>\n<p>Show IPs with more than 10 connections open:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# netstat -nat | grep &quot;:80&quot; | awk -F: &#039;{print $8}&#039; | sort | uniq -c | sort -n | awk &#039;{ if ( $1 &gt; 10) print $2 ; }&#039;\n\n<\/pre>\n<p>Show # of connections open per IP<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# netstat -nat | egrep &quot;:80|:443&quot; | awk -F: &#039;{print $8}&#039; | sort | uniq -c | sort -n \n\n<\/pre>\n<p>Number of connections per IP<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# netstat -anp |grep &#039;tcp\\|udp&#039; | awk &#039;{print $5}&#039; | cut -d: -f1 | sort | uniq -c | sort -n\n\n<\/pre>\n<p>Haynie&#8217;s version(better sorting):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# netstat -anp|awk &#039;{print $5}&#039;|awk -F: &#039;{print $4}&#039;|sort -n -t. -k1,1 -k2,2 -k3,3 -k4,4|uniq -c|sort -n\n\n<\/pre>\n<p>Drop ips with 100 or more connections:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# netstat -nat | egrep &quot;:80|:443&quot; | awk -F: &#039;{print $8}&#039; | sort | uniq -c | sort -n | awk &#039;{ if ( $1 &gt; 100) print $2 ; }&#039; | xargs -n1 echo iptables -I INPUT -j DROP -s\n\n<\/pre>\n<p>Graphic netstat connections(# of connections open per host)<\/p>\n<p># netstat -an | grep ESTABLISHED | awk &#8216;{print $5}&#8217; | awk -F: &#8216;{print $1}&#8217; | sort | uniq -c | awk &#8216;{ printf(&#8220;%s\\t%s\\t&#8221;,$2,$1) ; for (i = 0; i < $1; i++) {printf(\"*\")}; print \"\" }'\n\n[\/bash]\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Useful commands to check if a server is getting ddos&#8217;d Show IPs with more than 10 connections open: # netstat -nat | grep &quot;:80&quot; | awk -F: &#039;{print $8}&#039; | sort | uniq -c | sort -n | awk &#039;{ if ( $1 &gt; 10) print $2 ; }&#039; Show # of connections open per &#8230; <a title=\"Netstat Commands for DDoS Checking\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/04\/06\/netstat-commands-for-ddos-checking\/\" aria-label=\"Read more about Netstat Commands for DDoS Checking\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"class_list":["post-2121","post","type-post","status-publish","format-standard","hentry","category-networking"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2121"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2121\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}