首页 > 我的文章 > PHP开发 > nginx > linux 查看访问本机ip次数

linux 查看访问本机ip次数

浏览:861 编辑:绿萝 来源:绿萝
linux 查看访问本机ip次数
查看访问本机ip次数
netstat -tn |grep :80|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c |sort -n|grep -v Address|grep -v servers

用root身份执行
iptables -t filter -A INPUT -s 192.168.0.5 -i eth0 -j DROP

(禁止ip地址192.168.0.5从eth0访问本机)



netstat -ntu | tail -n +3 | awk '{print $5}' | sort | uniq -c | sort -nr

直接通过 netstat 的信息,把与本地相关的各种状态的 IP 都计数,排序列出来。




或者从 nginx 或者其他 web server 的日志里找请求数太多的 IP

awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr
netstat -ntu | tail -n +3 | awk '{print $5}' | sort | uniq -c | sort -nr 去除黑名单,与此同时,又可以访问了 
ipset del openapi 180.156.238.246