List top 20 IP from which TCP connection is in SYN_RECV state

netstat -pant 2> /dev/null | grep SYN_ | awk '{print $5;}' | cut -d: -f1 | sort | uniq -c | sort -n | tail -20
List top 20 IP from which TCP connection is in SYN_RECV state. Useful on web servers to detect a syn flood attack. Replace SYN_ with ESTA to find established connections
Sample Output
1 125.162.92.184
      1 125.164.121.250
      1 125.71.93.177
      1 128.107.229.110
      1 189.147.101.11
      1 202.40.210.145
      1 202.40.210.164
      1 203.130.201.198
      1 41.201.190.148
      1 41.201.238.148
      1 81.199.44.161
      1 81.202.11.253
      2 202.134.71.158
      7 218.4.59.190

3
2009-02-16 08:49:38

These Might Interest You

  • Show state of NAT, readed from '/proc/net/ip_conntrack' or '/proc/net/nf_conntrack' Show Sample Output


    0
    netstat-nat -n
    slezhuk · 2012-05-29 13:12:06 0
  • Lots of fun to run on nfs clients when the server or network connection is having issues


    1
    ps aux | awk '{if ($8 ~ "D") print $0}'
    SEJeff · 2012-05-25 16:53:57 0
  • SSH can be controlled trough an ~ escape sequence. Example, to terminate the current ssh connection, type a newline, then the ~ character, and last a . character. This is useful eg when an ssh connection hangs after you reboot a machine and the connection hangs. Show Sample Output


    31
    [enter]~?
    xeor · 2011-06-17 18:29:59 3
  • Outputs Windows Services service name and display name using "sc query", pipes the output to "awk" for processing, then "column" for formatting. List All Services: sc query state= all | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\: List Started Services: sc query | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\: List Stopped Services: sc query state= inactive| awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\: Show Sample Output


    1
    sc query state= all | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
    lowjax · 2015-02-15 22:35:10 2

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: