LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Closed Thread
  Search this Thread
Old 03-15-2008, 02:32 PM   #1
linux_linux
Member
 
Registered: Mar 2008
Posts: 52

Rep: Reputation: 15
Linux - Determine number of unique hosts connected to server


Normally; I would use netstat -a | grep <port number>
To see a list or to get a count of how many connections to a particular port. However, I need a bit more granular output so that I can also see the number of UNIQUE hosts connected to that port. Otherwise, the current output I am getting will show multiple connections a host may have; which doesn't give me an accurate 'count' of total UNQIUE hosts connected.

Thanks
 
Old 03-15-2008, 04:21 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The "sort" command
Code:
netstat -v -A inet | sed -n  '1,2d;/www-http/p;' | sort -b -k5
tcp        1      0 192.168.1.104:29961     12.120.5.14:www-http    CLOSE_WAIT
tcp        1      0 192.168.1.104:29962     12.120.5.14:www-http    CLOSE_WAIT
tcp        0      0 192.168.1.104:23120     128.242.191.11:www-http ESTABLISHED
tcp        0      0 192.168.1.104:4556      128.242.191.58:www-http CLOSE_WAIT
tcp        1      0 192.168.1:bluectrlproxy 209.62.187.18:www-http  CLOSE_WAIT
tcp        0      0 192.168.1.104:5685      feeds.feedburn:www-http ESTABLISHED
tcp        0      0 192.168.1.104:5686      feeds.feedburn:www-http ESTABLISHED
tcp        0      0 192.168.1.104:5687      feeds.feedburn:www-http ESTABLISHED
tcp        0      0 192.168.1.104:ggz       feeds.feedburn:www-http ESTABLISHED
tcp        1      0 192.168.1.104:10934     od-in-f166.goo:www-http CLOSE_WAIT
tcp        1      0 192.168.1.104:10935     od-in-f166.goo:www-http CLOSE_WAIT
tcp        1      0 192.168.1.104:29115     www.linuxquest:www-http CLOSE_WAIT

netstat -v -A inet | sed -n  '1,2d;/www-http/p;' | sort -b -k5 -u
tcp        1      0 192.168.1.104:29961     12.120.5.14:www-http    CLOSE_WAIT
tcp        0      0 192.168.1.104:23120     128.242.191.11:www-http ESTABLISHED
tcp        0      0 192.168.1.104:4556      128.242.191.58:www-http CLOSE_WAIT
tcp        1      0 192.168.1:bluectrlproxy 209.62.187.18:www-http  CLOSE_WAIT
tcp        0      0 192.168.1.104:5685      feeds.feedburn:www-http ESTABLISHED
tcp        1      0 192.168.1.104:10934     od-in-f166.goo:www-http CLOSE_WAIT
tcp        1      0 192.168.1.104:29115     www.linuxquest:www-http CLOSE_WAIT
The fifth entry looked so strange that I added a rule in iptables to drop that IP.
 
Old 03-15-2008, 09:41 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I'd like to discourage members to respond to these posts.
This is the product of a SPAM bot.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find out number of users connected to my sftp server procfs Linux - Newbie 5 01-10-2008 10:47 PM
pls help on how i can generate 4 digit random number that are unique within the set icylicious Programming 7 08-22-2006 01:00 PM
Trying to get unique system id (serial number) with FC4 dmattice Linux - Hardware 2 01-21-2006 05:42 PM
Unique identify motherboards (ID / serial number). How to? FredKroket Programming 2 05-12-2005 01:06 AM
How do you determine the number of NFS instances to start? BrianK Linux - Networking 6 10-26-2004 05:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration