Problem receiving UDP broadcast packets.

Grant Edwards invalid at invalid.invalid
Wed Apr 20 16:35:31 CEST 2011

On 2011-04-20, Thomas Heller <theller at> wrote:
> Am 20.04.2011 00:21, schrieb Grant Edwards:
>> I'm have problems figuring out how to receive UDP broadcast packets on
>> Linux.
> [...]
>> On the receiving machine, I've used tcpdump to verify that broadcast
>> packets are being seen and have a destination IP of and
>> destination MAC of ff:ff:ff:ff:ff:ff
> [...]
>> But, the receiving Python program never sees any packets unless the
>> _source_ IP address in the packets is on the same subnet as the
>> receiving machine.  In this test case, the receiving machine has an IP
>> address of  If I change the receiving machine's IP
>> address to, then the receiving program sees the packets.
>> Even though the destination address is, the receiving
>> machine appears to discard the packets based on the _source_ IP.  Can
>> anybody provide example Python code for Linux that receives UDP
>> broadcast packets regardless of their source IP address?
>> This probably is more of a Linux networking question than a Python
>> question, but I'm hoping somebody has solved this problem in Python.
> You must set the network interface to promiscous mode on the
> receiving side:
> os.system("ifconfig eth0 promisc")


The network interface is already receiving the packets I want, since
they're beign sent with a destination MAC of ff:ff:ff:ff:ff:ff.

Grant Edwards               grant.b.edwards        Yow! Spreading peanut
                                  at               butter reminds me of
                                opera!!  I wonder why?

More information about the Python-list mailing list