Changes

Jump to: navigation, search

Traffic accounting with iptables

144 bytes removed, 19:11, 20 November 2006
use vzlist whenever possible in Scripting
<pre>
host2:~/bin# cat vz-all-running
vzlist |grep run|tr -s [:blank:]|cut H -d' ' -f2oveid
</pre>
<pre>
host2:~/bin# cat vz-all-running-ip
for i in `./vzvzlist -allH -running`; do vzctl exec $i ifconfig |grep 'venet0:0' -A1|tail -n1|cut -d':' -f2|cut -d' ' -f1; doneo ip
</pre>
<pre>
host2:~/bin# cat vz-iptables-create-rules
for i in `./vz-all-running-ip`; do iptables -D FORWARD -s $i; iptables -D FORWARD -d $i; done >/dev/null 2>/dev/null&1for i in `./vz-all-running-ip`; do iptables -A FORWARD -s $i; iptables -A FORWARD -d $i; done >/dev/null 2>/dev/null&1
</pre>
iptables -Z
</pre>
 You can use crontab to run this script once per hour or day to collect your traffic statistics.
As you see this way can be time-consuming in case of big number of VEs.
So if anybody has scripts that automate all the process - you are welcome! 
[[Category: HOWTO]]
[[Category: Networking]]

Navigation menu