Socket bound to 0.0.0.0 never receives broadcasts with non-zero IP source address
Daniel Corbe
corbe at corbe.net
Wed Apr 8 12:44:07 UTC 2015
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 at 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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
More information about the freebsd-net
mailing list