iT邦幫忙

0

Windows / Linux 如何查詢連線數量(connections & sessions)

唬爛 2010-06-28 17:43:2761252 瀏覽

請問各位先進:
Windows / Linux 如何查詢連線數量? (connections & sessions)
問題描述
Firewall:Linux平台(Endian 2.3)
Server:Windows 2008 R2 x64 (Web Service為IIS 7.0)
目前有一需求,想分別透過防火牆 & Server查詢目前如:80 Port (or 其他Port)即時連線數量
雖然防火牆有提供即時連線畫面,但更新速度太快(找不到選項調整),根本無法細看
而已知共用指令:netstat -a & Windows tools:TcpView,卻因 Windows 2008 R2 x64 之 dns.exe 會產生大量UDP連線,詳見 http://ithelp.ithome.com.tw/question/10045461,此一問題,也無法細看
經Google搜尋,有網友提供

  1. 查詢http連線數
    ps auxwww | grep http | wc
  2. 查詢SYN_RECV 數
    netstat -an | grep SYN_RECV | wc
    小弟在防火牆command line試過,每次執行結果都顯示個位數(不管小弟是否有開網頁,結果都一樣,是否該方法需Linux本身是Web Server才會正確?)
    小弟不才,Google大半天仍找不到解答(以Windows、Linux、connections、sessions為關鍵字)
    請教各位先進,是否有Linux & Windows建議之指令 or tools,可達到小弟之需求
    or 給小弟提示提示一下(比如Google如何下關鍵字)
    PS:小弟的即時連線數量,是指下完命令後,當下之連線資訊,不需要時時自動更新
    以上請各位先進指導,謝謝
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

12
Ray
iT邦大神 1 級 ‧ 2010-06-28 20:15:36
最佳解答

Linux:
看全部: netstat -aunt | wc -l
只看 TCP: netstat -ant | wc -l
只看 UDP: netstat -aut | wa -l

Windows:
只看TCP: netstat -an | find "TCP" /c
只看UDP: netstat -an | find "UDP" /c

看更多先前的回應...收起先前的回應...
Ray iT邦大神 1 級 ‧ 2010-06-28 20:30:55 檢舉

上面有個打錯字了....Orz......

Linux:
只看 UDP: netstat -aut | wc -l

.....真是的....wc 怎麼會打成 wa.....IThelp 又不讓人修改內容....@!&%&#$%&@$

Ray iT邦大神 1 級 ‧ 2010-06-28 20:32:33 檢舉

又打錯字了....唉.....頭昏眼花的....

Linux:
只看 UDP: netstat -aun | wc -l

....@*!O^$*@#$^@(*#$^#@*^$.....該死的 ITHelp....不能修改....*!@*$*@#$#

Ray iT邦大神 1 級 ‧ 2010-06-28 20:38:09 檢舉

我該去睡了....大概是今天一整天都在轉 Exchange 2003 到 2010, 給搞到昏頭轉向....

唬爛 iT邦好手 1 級 ‧ 2010-06-29 10:39:01 檢舉

恕刪...
晚輩受教了(Linux之netstat --help,竟無顯示-u & -t兩參數)
有一疑問,前輩所用之指令,應當都屬本機指令
若Server在防火牆內部,因所有連線應當都會經由防火牆出去,那有無指令 or 方法可查詢防火牆所有對外連線(如:有多部Web Server,想統計有多少80 Port連線...),也想了解防火牆最大連線數界限
以上,謝謝

Ray iT邦大神 1 級 ‧ 2010-06-29 22:50:56 檢舉

我了解您的需求, 但是沒有固定的指令可以完成您的需求, 各系統都不相同.
由於您使用 Endian Firewall, 小弟沒有接觸過, 無法提供明確的方法, 不過....

如果您可以進去下指令的話, 請輸入這個指令試試看:
iptables -L | grep Chain
他應該會列出很多東西, 請讓我看看, 是否有辦法從裡面找出線索?

如果沒有東西的話, 小弟就幫不上忙了.....

唬爛 iT邦好手 1 級 ‧ 2010-07-09 15:12:52 檢舉

root@efw:~ # iptables -L | grep Chain
Chain INPUT (policy DROP)
Chain FORWARD (policy DROP)
Chain OUTPUT (policy ACCEPT)
Chain ALLOW (182 references)
Chain ALLOW_HOOKS (1 references)
Chain BADTCP (2 references)
Chain BADTCP_LOGDROP (9 references)
Chain CUSTOMFORWARD (1 references)
Chain CUSTOMINPUT (1 references)
Chain CUSTOMOUTPUT (1 references)
Chain HAFORWARD (1 references)
Chain ICMP_LOGDROP (2 references)
Chain INCOMINGFW (1 references)

唬爛 iT邦好手 1 級 ‧ 2010-07-09 15:13:05 檢舉

Chain INPUTFW (8 references)
Chain INPUTFW_LOGDROP (7 references)
Chain INPUTTRAFFIC (1 references)
Chain LOG_FORWARD (1 references)
Chain LOG_INPUT (1 references)
Chain NEWNOTSYN (0 references)
Chain NEWNOTSYN_LOGDROP (2 references)
Chain OPENVPNCLIENTDHCP (1 references)
Chain OPENVPNDHCP (1 references)
Chain OUTGOINGFW (1 references)
Chain PORTFWACCESS (1 references)
Chain REDINPUT (1 references)
Chain SNORT (1 references)
Chain VPNFW (10 references)
Chain VPNFWDST (1 references)
Chain VPNFW_LOGDROP (10 references)
Chain VPNTRAFFIC (1 references)
Chain ZONEFW (4 references)
Chain ZONEFW_LOGDROP (4 references)
Chain ZONETRAFFIC (1 references)

我要發表回答

立即登入回答