Date: Tue, 07 Apr 2015 18:50:15 -0700 From: Yuri <yuri@rawbw.com> To: net@freebsd.org Subject: Socket bound to 0.0.0.0 never receives broadcasts with non-zero IP source address Message-ID: <55248957.60109@rawbw.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55248957.60109>
