|
发表于 2004-1-10 11:59:30
|
显示全部楼层
- pop:~# iptables -L r0 -v -n
- Chain r0 (1 references)
- pkts bytes target prot opt in out source destination
- 13662 601K DROP all -- * * 61.153.3.7 0.0.0.0/0
- 146 7564 DROP all -- * * 61.50.176.0/20 0.0.0.0/0
- 190 9120 DROP all -- * * 61.62.80.0/20 0.0.0.0/0
- 716 34804 DROP all -- * * 61.141.224.0/20 0.0.0.0/0
- 81 4368 DROP all -- * * 61.177.32.0/20 0.0.0.0/0
- 822 40484 DROP all -- * * 202.107.192.0/20 0.0.0.0/0
- 2887 150K DROP all -- * * 210.51.0.0/16 0.0.0.0/0
- 1897 91152 DROP all -- * * 211.97.176.0/20 0.0.0.0/0
- 3237 155K DROP all -- * * 218.61.0.0/16 0.0.0.0/0
- 246 11832 DROP all -- * * 218.5.160.0/20 0.0.0.0/0
- 12954 637K DROP all -- * * 218.17.0.0/16 0.0.0.0/0
- 22044 1105K DROP all -- * * 218.18.0.0/16 0.0.0.0/0
- 4658 232K DROP all -- * * 218.20.0.0/16 0.0.0.0/0
- 98 4800 DROP all -- * * 218.58.96.0/20 0.0.0.0/0
- 265 13712 DROP all -- * * 218.79.224.0/20 0.0.0.0/0
- 1838 90812 DROP all -- * * 218.80.0.0/16 0.0.0.0/0
- 130 6240 DROP all -- * * 218.246.224.0/20 0.0.0.0/0
- 6 384 DROP all -- * * 218.6.0.0/20 0.0.0.0/0
- 439 21072 DROP all -- * * 219.137.64.0/20 0.0.0.0/0
- 1369 65920 DROP all -- * * 219.233.0.0/16 0.0.0.0/0
- 3948 192K DROP all -- * * 219.237.0.0/16 0.0.0.0/0
- 563 27168 DROP all -- * * 220.113.160.0/20 0.0.0.0/0
- 264 12672 DROP all -- * * 221.10.208.0/20 0.0.0.0/0
复制代码
这是一些网段的drop,只要改为accept就能实现流量的统计。至于统计ip还是端口的流量大家就自由发挥了,写个几百条总能满足需要的。然后结合脚本进行界面更改,简化操作就比较完善了。
- [root@gateway root]# showquota
- error: time parameter error!
- example: showquota {number}
- [root@gateway root]# showquota 1
- wxy quota: 573079855 bytes
- zc quota: 570164706 bytes
- yj quota: 566660319 bytes
- wh quota: 464174942 bytes
- yh quota: 497620615 bytes
- dhf quota: 582565272 bytes
- zxl quota: 591052139 bytes
- lhf quota: 541141789 bytes
- xmj quota: 572473650 bytes
- yz quota: 584613165 bytes
- sh quota: 583436152 bytes
- tk quota: 587226497 bytes
- lz quota: 0 bytes
- djr quota: 599981001 bytes
- fmd quota: 588132717 bytes
- tyl quota: 595405020 bytes
- ws quota: 105356325 bytes
- zqy quota: 567967421 bytes
- fw quota: 600000000 bytes
- shl quota: 596977562 bytes
- 192.168.17.0/24
- Please press ^c quit....
复制代码
这里的quota功能是较新版的iptables所带有的,界面经过我略微加工了一下。showquota:
- [root@gateway root]# cat /usr/sbin/showquota
- #!/bin/bash
- if [ $# != "1" ];then
- echo "error: time parameter error!";
- echo "example: showquota {number}";
- exit;
- fi
- while true;do
- clear
- iptables -L QUOTA | awk '{ print $5"\t"$6" "$7" "$8}' | sed -e '1,2d'
- echo ""
- echo ""
- echo -n "Please press ^c quit...."
- sleep $1
- done
- [root@gateway root]# cat monitor
- #!/bin/bash
- if [ $# != "1" ];then
- echo "error: time parameter error!";
- echo "example: monitor {number}";
- exit;
- fi
- iptables -Z FORWARD
- while true;do
- clear
- iptables -L FORWARD -v | sed -e '1d' | awk '{print $1"\t"$2"\t"$8"\t\t"$9}'
- echo ""
- echo ""
- echo -n "Please press ^c quit...."
- iptables -Z FORWARD
- sleep $1
- done
复制代码
monitor是我为了方便监视每个客户端流量而写的,每个ip在hosts文件中都有对应的名字。写得都很简单,如果大家有兴趣可以完善一下。 |
|