久久青草精品A片狠狠,日韩欧美视频一区二区,亚洲国码AV日韩,国产精品黄在

Linux下如何對端口流量進行統計

2019-05-16 14:31:30 10007

添加需要統計的端口


1、輸入監控


下面示例是監控目標端口是8080的輸入流量 --dport(destination port 的縮寫)


iptables -A INPUT -p tcp --dport 8080

2、輸出監控


下面示例是監控來源端口是8080的輸出流量 --sport(source port 的縮寫)


iptables -A OUTPUT -p tcp --sport 8080

查看統計數據


iptable -L -v -n -x

示例結果:


8080端口接收的流量為2885字節,發送的流量是8240字節


Chain INPUT (policy ACCEPT 202 packets, 25187 bytes)

  pkts   bytes target   prot opt in   out   source        destination     

   18   2885      tcp -- *   *    0.0.0.0/0      0.0.0.0/0      tcp dpt:8080

 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)

  pkts   bytes target   prot opt in   out   source        destination     

 

Chain OUTPUT (policy ACCEPT 184 packets, 45774 bytes)

  pkts   bytes target   prot opt in   out   source        destination     

   12   8240      tcp -- *   *    0.0.0.0/0      0.0.0.0/0      tcp spt:8080

重置統計數據


注意:這里是重置所有端口的統計數據


1、重置所有輸入端口


Iptable -Z INPUT

2、重置所有輸出端口


Iptable -Z OUTPUT

移除統計端口


1、移除輸入端口


iptables -D INPUT -p tcp --dport 8080

2、移除輸出端口


iptables -D OUTPUT -p tcp --sport 8080


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: