Skip to content Skip to sidebar Skip to footer

Sending A Udp Packet With Source Port, But Without Binding

I would like to send a UDP packet in Python and specify the source port but WITHOUT binding. An equivalent with hping3: hping3 -s $sourceport -p $remoteport --udp --file message.bi

Solution 1:

There's no API for sending an UDP packet with a defined source port in python , nor on most (all?) the operating systems python runs on without binding the socket to a local port first.

So you'll have to bind() your socket if you want to control the source port.

If bind() "does not work", then you're either binding to a port that another process owns, or a port number < 1024 which only the root user can bind to, or you're giving some other wrong parameters to bind() - but we'd need more info to help you, e.g. the error message you get, the actual parameters you pass to bind, etc.

Post a Comment for "Sending A Udp Packet With Source Port, But Without Binding"