在 CentOS 上并没有一个叫 Sniffer 的命令,通常是指 使用抓包工具查看网络数据包。下面按常用场景给你说明。
yum install -y tcpdump
ip addr
# 或
ifconfig
tcpdump -i eth0
tcpdump -i eth0 -nn # 不解析主机名和端口名
tcpdump -i eth0 -c 100 # 只抓100个包
tcpdump -i eth0 port 80 # 只抓80端口
tcpdump -i eth0 host 192.168.1.10
tcpdump -i eth0 tcp
tcpdump -i eth0 -w test.pcap # 保存到文件
tcpdump -r test.pcap
ss -antp
netstat -antp
yum install -y wireshark-cli
tshark -i eth0
tshark -i eth0 -Y "http"
tshark -i eth0 -w test.pcap
CentOS 服务器一般不建议装,但可以做:
yum install -y wireshark
wireshark
⚠️ 需要 X11 或远程桌面支持
tcpdump -i eth0 host 192.168.1.100
tcpdump -i eth0 port 80 -A
tcpdump -i eth0 port 53
抓包需要 root 权限:
sudo tcpdump -i eth0
或
su -
tcpdump -i eth0 -nn -c 1000 -w capture.pcap
然后在本地用 Wireshark 打开 capture.pcap 分析。
如果你能告诉我:
我可以直接给你 最精准的命令。