Tcpdump 使用文件轮换将 pcap 写入远程服务器
Tcpdump write pcap to remote server with file rotation
我正在尝试 运行 在 linux 机器上进行 tcpdump,这需要在远程服务器上写入 pcap,每 10 秒进行一次文件轮换。
tcpdump -s0 -i eth0 -G 10 -w - | ssh {remote_ip} "cat > capture_%d-%m_%Y__%H_%M.pcap"
文件在第一个周期(10 秒)在远程服务器上获取 return,然后出现以下错误。
tcpdump: listening on ens224, link-type EN10MB (Ethernet), capture size 262144 bytes
tcpdump: Can't write to standard output: Bad file descriptor
我正在使用 -G
进行基于时间的轮换,如果我删除 -G
,那么我就可以连续写入远程服务器。
我的远程服务器配置为从该主机无密码登录。
您可以将 tcpdump 传输到另一个 tcpdump,因此在您的情况下:
tcpdump -i eth0 -w - not port 22 | \
ssh my.remote.host tcpdump -r - -w /tmp/capture_%d-%m_%Y__%H_%M_%S.pcap -G 2 -C 100
我正在尝试 运行 在 linux 机器上进行 tcpdump,这需要在远程服务器上写入 pcap,每 10 秒进行一次文件轮换。
tcpdump -s0 -i eth0 -G 10 -w - | ssh {remote_ip} "cat > capture_%d-%m_%Y__%H_%M.pcap"
文件在第一个周期(10 秒)在远程服务器上获取 return,然后出现以下错误。
tcpdump: listening on ens224, link-type EN10MB (Ethernet), capture size 262144 bytes
tcpdump: Can't write to standard output: Bad file descriptor
我正在使用 -G
进行基于时间的轮换,如果我删除 -G
,那么我就可以连续写入远程服务器。
我的远程服务器配置为从该主机无密码登录。
您可以将 tcpdump 传输到另一个 tcpdump,因此在您的情况下:
tcpdump -i eth0 -w - not port 22 | \
ssh my.remote.host tcpdump -r - -w /tmp/capture_%d-%m_%Y__%H_%M_%S.pcap -G 2 -C 100