Re: Do UDP broadcasts work in FreeBSD?



On Jan 6, 2009, at 8:49 AM, Peter Steele wrote:
Our efforts so far indicate the answer is no, which baffles us. We want
to send a limited broadcast to 255.255.255.255 but the message never
arrives. The same code works fine under Linux. Is there a trick for
doing this kind of thing under FreeBSD?

What you're trying to do with sending to the all-ones broadcast address is known as sending a "link-local" packet. On some systems, sending a UDP packet to 255.255.255.255 will actually cause a packet with that destination to be generated from all network interfaces which are "UP". That seems to be the behavior you are expecting.

On FreeBSD, IIRC, the behavior you get is that it will send to the local network broadcast address for each interface [1] using the network broadcast address (ie, if an interface is configured for 10.1.1.1 with /16 netmask, the packet will have destination 10.1.255.255). If an interface is UP but not configured with an IP +netmask, I don't believe a packet will be sent. (In fact, it might depend upon whether the BROADCAST flag is enabled, which gets set when an inet-enabled interface is setup with a netmask...)

Arguably, this is a bug in FreeBSD, but you can work around it by using the BPF interface to send the traffic directly rather than using the network stack via socket()+send()/write(). I believe the ISC DHCP server software provides examples of how to do this, as dhclient is commonly used to send DHCP requests to the all-ones broadcast addr, without needing an interface being configured with an IP....

--
-Chuck

[1]: And I could be mis-remembering that part; it might do a routing table lookup and use only the interface which matches the destination IP, which is probably the default route.

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: broadcast udp packets ...
    ... The listener listens for an 'appliance discovery' packet which is ... > reply back with a broadcast packet that says 'here I am' so the console ... addressed to an interface which is UP but does not have an IP address configured ...
    (freebsd-net)
  • RE: Do UDP broadcasts work in FreeBSD?
    ... address is known as sending a "link-local" packet. ... local network broadcast address for each interface using the ... So we've come up with our own "light" DHCP. ...
    (freebsd-questions)
  • Re: broadcast udp packets ...
    ... When I use a udp socket bound to an interface, ... > would seem that if you were requesting the packet be routed, ... It's a broadcast, the socket isn't bound to an interface. ...
    (freebsd-net)
  • Re: How to enable "Subnet Directed Broadcasts" in RRAS?
    ... packet on one interface and then you could have it broadcast out to the ... where the router listens for packet X which could be received as either a ... broadcast or unicast, and then rebroadcasts it out its other interface on ...
    (microsoft.public.win2000.ras_routing)
  • RE: Intrusion Prevention requirements document
    ... The tools consider one interface as "client" and other ... Packet 1 is first sent out on client interface. ... > my previous company was Blade Software where I developed IDS Informer ... Up to 75% of cyber attacks are launched on shopping carts, ...
    (Pen-Test)