문제

From the netcat man page one can sniff / save a TCP stream using something like:

mkfifo data
cat data | nc -l $port | tee -a $fn1 | nc $server $port | tee -a $fn2 > data

So I tried something like the following to do the same for UDP:

mkfifo data
cat data | nc -lu $port | tee -a $fn1 | nc -u $server $port | tee -a $fn2 > data

But it fails miserably, which I assume is because of the race conditions between writing to and reading from data and the pipe out of the tee command meaning I can't guarantee that UDP packets are transmitted one-by-one.

Is there an existing command or tool I can use to sniff UDP conversations without altering the packets? Preferably a 1-liner bash command, though a short ruby or python or whatever script works too.

도움이 되었습니까?

해결책

socat -x "udp-listen:$port" "udp:$server:$host" 2> logfile
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top