Packet Capture and Retransmission, socat permission denied

142 Views Asked by At

I am trying to do packet capture and retransmission using a raspberrypi using tcpdump and socat. However i keep getting the error:

tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 2023/09/26 20:17:17 socat[2400] E sendto(5, 0x3fb000, 24, 0, AF=2 192.168.7.255:14555, 16): Permission denied

Please help me out.

this sis the shell script `#!/bin/bash

Define the multicast group and port to capture

multicast_group="224.1.1.1" # Replace with your specific multicast group address multicast_port=12345 # Replace with the multicast port number

Define the broadcast address and port to retransmit

broadcast_address="192.168.xxx.xxx" # Broadcast address for the target network forward_port=54321 # Replace with the port number you want to use for forwarding

while true; do

Start tcpdump to capture UDP multicast packets

sudo tcpdump -i eth0 -n -s0 -U -w - "udp and port $multicast_port" |
sudo socat -u - UDP4-DATAGRAM:$broadcast_address:$forward_port done `

I tried using sudo to make it executable but that did not work.

1

There are 1 best solutions below

0
dest-unreach On

See man 5 socket:

SO_BROADCAST Set or get the broadcast flag. When enabled, datagram sockets are allowed to send packets to a broadcast address. This option has no effect on stream-oriented sockets.

In Socat you set this flag with the so-broadcast option:

sudo socat -u - UDP4-DATAGRAM:$broadcast_address:$forward_port,so-broadcast