在 CentOS 上提到“sniffer 分析日志”,通常有两种理解:
下面我分别说明常见做法。
yum install -y tcpdump
tcpdump -i eth0 -nn
tcpdump -i eth0 -w /tmp/capture.pcap
tcpdump -r /tmp/capture.pcap
# 把 pcap 拷出来用 Wireshark 打开
# 只看某 IP
tcpdump host 192.168.1.10
# 只看某端口
tcpdump port 80
# 只看 TCP
tcpdump tcp
# 排除某 IP
tcpdump not host 192.168.1.1
/var/log/messages # 系统日志
/var/log/secure # 认证、SSH 登录
/var/log/dmesg # 内核日志
/var/log/httpd/ # Apache
/var/log/nginx/ # Nginx
tail -f /var/log/messages
# 查看当前连接
ss -antp
# 或
netstat -antp
grep "Failed password" /var/log/secure
journalctl -xe
journalctl -u sshd
yum install -y wireshark
tshark -r capture.pcap
grep / awk / sedgoaccess(Web 日志)yum install -y goaccess
goaccess /var/log/nginx/access.log -o report.html
tcpdump 抓包/var/log/secure、messagesss/netstat 看连接如果你能具体说一下:
我可以给你更针对性的命令和示例。