Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Thomas Heller Newsgroups: comp.lang.python Subject: Re: Problem receiving UDP broadcast packets. Date: Wed, 20 Apr 2011 12:18:04 +0200 Lines: 29 Message-ID: <917q6sF3u7U1@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net hv1+aLklNiZWNyD4MDJySgYe5u0XpxyzEuZseYwz5RhTUYKvI= Cancel-Lock: sha1:XixcE25jc6LZBKBbOqq5vbnRxoY= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3679 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 255.255.255.255 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 172.16.12.34/16. If I change the receiving machine's IP > address to 10.0.0.123, then the receiving program sees the packets. > > Even though the destination address is 255.255.255.255, 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") Thomas