nginx控制流量
#limit_conn addr 100;
limit_rate 1k;
limit_rate_after 200k;
#limit_upload_rate 100k;
网络监控工具
vnstat -i eth0 -l
iftop -i eth0
nethogs eth0 -d 5
_________________________
iftop -n -m 100M -t -s 10 -L 10000 -f 'src port 80 or src port 443' > iftop_tkm.txt
sed '/=>/ d' iftop_tkm.txt > iftop_output.txt
awk '/[0-9]+.[0-9]+.[0-9]+.[0-9]+/{print $1}' iftop_output.txt > ip_bandwidth.txt
sort -nk 1 ip_bandwidth.txt > sorted_ips.txt
cat ip_bandwidth.txt |more
_________________________
iftop -i eth0 -nNP -m 100M -o 10s -s 10
iftop -i eth0 -nNP -m 100M -o 10s -s 10 -f 'src port 80 or src port 443'
iftop -i eth0 -nN -m 100M -t -s 10 -L 1000 -o destination > iftop_output.txt
iftop -i eth0 -nN -m 100M -t -s 10 -L 1000 -o destination -f 'src port 80 or src port 443' > iftop_output.txt
-n不解析dns -P带端口 -i指定网卡 -o 3秒刷新一次 -s 2表示排序
键盘单点 t
shift L 可以找出流量峰值最高的ip
shift T 可以查看接收和发送的流量总和
shift B 切换2秒 10秒 40秒统计
_________________________
iftop -i eth0 -f "src host 192.168.0.1" 来源主机
iftop -i eth0 -f 'dst port 6379' 目的
iftop -i eth0 -f 'not port 6379'
-o destination