Date: Wed, 08 Apr 2015 08:32:13 -0400 From: Daniel Corbe <corbe@corbe.net> To: Yuri <yuri@rawbw.com> Cc: net@freebsd.org Subject: Re: Socket bound to 0.0.0.0 never receives broadcasts with non-zero IP source address Message-ID: <878ue2n6lu.fsf@corbe.net> In-Reply-To: <55248957.60109@rawbw.com> (yuri@rawbw.com's message of "Tue, 07 Apr 2015 18:50:15 -0700") References: <55248957.60109@rawbw.com>
next in thread | previous in thread | raw e-mail | index | archive | help
If nobody answers this question by the time I get home I'll try and help; however, in the mean time I do have a couple of suggestions. Have you tried writing the equivalent program in C using the sockets API? IE is this a python specific problem or a sockets problem in general? The second thing is you may just want to try using raw sockets instead. -Daniel Yuri <yuri@rawbw.com> writes: > I noticed that the socket bound to '0.0.0.0' only receives UDP > broadcasts when they are sent from zero IP: > 0.0.0.0->255.255.255.255. When the source IP is not zeros, but some > valid IP on that network, socket never receives such broadcast. > > I compared two packets in wireshark as they arrive, and the only > difference on Ether/IP/UDP level is source IP. > > Is there any reason why source IP address would influence the > reception of the broadcast packets? > > I use this python3 program to create bound socket and listen: > #!/usr/bin/env python3.4 > import socket > sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) > sock.bind(('0.0.0.0', 67)) > print("Waiting for broadcast") > (data, flags, ancillary, addr) = sock.recvmsg(4096, 256) > print("Received broadcast packet") > > I use dhclient to send broadcast packets. It sends with src=0.0.0.0 > when no /var/db/dhclient.leases.* exists, and it always sends with > src=<previous lease> when the previous lease exists. > > 10.1 STABLE > > Yuri > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?878ue2n6lu.fsf>