2022-08-10-Linux服务器抓包过程

记录一次Linux服务器抓包过程

业务场景

EKS的某个pod(IP:172.29.21.165),给pinpoint服务器(IP:172.29.22.154)报送agent数据
在pinpoint服务器上监控网络传输包。

步骤

1、登陆Linux服务器

ssh -i ./*.pem ec2-user@172.29.22.154

2、安装tcpdump命令

安装教程
tcpdump官网下载地址,这个需要挂翻墙VPN,https://www.tcpdump.org/index.html#latest-releases

image-20220810142514937

3、输入ifconfig,查看linux服务器网卡和ip

[ec2-user@ip-172-29-22-154 ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.29.22.154 netmask 255.255.254.0 broadcast 172.29.23.255
inet6 fe80::84b:dcff:fe29:bb66 prefixlen 64 scopeid 0x20<link>
ether 0a:4b:dc:29:bb:66 txqueuelen 1000 (Ethernet)
RX packets 10819573974 bytes 8318273250206 (7.5 TiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7927277606 bytes 554950999560 (516.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4、使用tcpdump命令开始抓包,得到*.cap文件

[ec2-user@ip-172-29-22-154 ~]$ sudo tcpdump -i eth0 -w file.cap port 9993

注意:
tcpdump -i eth0 -w file.cap host 192.168.168.18 and tcp port 8081
-w :参数指定将监听到的数据包写入文件中保存,file.cap就是该文件。
-i :参数指定tcpdump监听的网络界面。

tcpdump的使用详情可以参考的博客地址:
linux服务器抓包实例

linux下如何使用 tcpdump 进行抓包详细教程

5、如何打开*.cap文件,进行分析

本机安装wireshark抓包工具软件,使用其打开cap文件。

Wireshark过滤语法

打开实例如图:

image-20220810144727891

发布于

2022-08-10

更新于

2022-08-10

许可协议

评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...