0

I have a subnet /24 (256 public IP addresses). Currently, I assign IP .255 to an LXD container (ubuntu) and it seems working normally. I wonder if someone sends a UDP message to the host that has IP .255 over the internet, will that message get broadcasted to all of my other IP?

  • 3
    Why do you assign the broadcast IP in the first place? That doesn't make any sense. – Gerald Schneider Jul 7 at 10:09
  • 1
    This post is a little confusing. I assume this host with .255 isn't part of your public IP range? And I find it very hard to believe your public IP is a /24. In answer to your question though, almost certainly not. – Dan Jul 7 at 10:15
  • 5
    What do you mean by "class C"? Classes are a historical artifact and were eliminated in the early 1990s. We do not refer to them anymore as if they were actually in use. – Michael Hampton Jul 7 at 12:24
  • 1
    Network classes are dead (please let them rest in peace), killed in 1993 (two years before the commercial Internet!) by RFCs 1517, 1518, and 1519, which defined CIDR (Classless Inter-Domain Routing). – Ron Maupin Jul 7 at 16:52
  • 2
    @dk1111, if the network is a /24 network, then using the .255 address will actually interrupt every host on the network to get to the one host with that address. Many people call any /24 network a Class C network, but that is most often incorrect. For example, 10.11.12.0/24 is often called a Class C network, but it is clearly a Class subnet because the first bit of the address starts with 0. See the very last section of this two-part answer to learn about the deprecated network classes. – Ron Maupin Jul 7 at 23:53
5

You need to understand some things.

First, a host only knows about the Limited Broadcast address (255.255.255.255), and its own network broadcast address (the last address in the network as defined by the network mask configured on the host). Packets sent to either of those addresses will not travel beyond the network on which they are sent.

For any addresses outside the network of the host, the host has no idea if the address is a host, network, or broadcast address. The host only knows it is an IPv4 address (IPv6 does not have broadcast). For example, a destination /23 (or smaller) network will have valid .0 and .255 host addresses.

The final router in the path is directly connected to the destination network and will know the destination network mask, so it will determine if the destination address is a broadcast or network address. By default, such a router will drop packets sent to the network or broadcast address of a directly connected network. The router could be configured to allow a broadcast destination (directed broadcast), but that would be foolish because it facilitates DoS attacks on the network (broadcasts interrupt every host on a network, and are considered wasteful and obsolete, which is why they were eliminated in IPv6).

| improve this answer | |
  • thanks. For short, the broadcast address only works if I send a packet from a host inside that network, correct? – dk1111 Jul 7 at 23:44
  • 1
    That is the default. As I explained, a router can be configured to allow a directed broadcast, but that would not be a good idea if it can be reached from the public Internet because you open yourself to a world of hurt. – Ron Maupin Jul 7 at 23:47
2

The notion of .255 as an IPv4 broadcast address exists only within the /24 net it belongs to. The global Internet does not know or care whether that address happens to be the broadcast address of the destination network. Therefore an IP packet sent to that address will be routed normally until it reaches the router responsible for final delivery to that address range, ie. which is either directly connected to the L2 network carrying the /24 net or which has a NAT rule transforming it to a different destination address.

What happens next depends on the configuration on that router.

  • If the destination router is directly connected to an Ethernet segment carrying the /24 IPv4 net in question and configured to forward directed broadcasts to it, and does not do NAT then yes, the packet will be broadcasted to all hosts on that segment. (Note that it will not be broadcasted to all IP addresses, as your question seems to imply. It will be sent to the broadcast MAC address, but with its original .255 destination IP address. This will cause all network interfaces on the segment to receive it, but each receiving host will see that it is addressed to the broadcast IP address, not to its unicast address, and be free to ignore it for that reason.)
  • In most cases however the destination router will be configured to drop packets to the directed broadcast address. This is the default since RFC2644.
  • Often public IPv4 addresses are transformed into private ones before delivery via NAT. In that case, the .255 address is treated no differently from any other. It is looked up in the NAT table and replaced by whatever actual destination address was found there. No broadcast happens. So the .255 address is not considered a broadcast address in that case.

Those are the most frequent cases. Others are possible but can be solved along the same lines.

| improve this answer | |
  • "If it is a regular router without NAT or packet filtering, and directly connected to an Ethernet segment carrying the /24 IPv4 net in question then yes, the packet will be broadcasted to all hosts on that segment." No, that was changed in 1999 by RFC 2644, Changing the Default for Directed Broadcasts in Routers. Prior to that, yes, a router was obligated by RFC to do just that, but the RFC changed the default behavior of routers so that the packets must be dropped unless the router is specifically configured to allow it. – Ron Maupin Jul 7 at 17:35
  • Thanks for pointing this out. I have corrected the paragraph accordingly. – Tilman Schmidt Jul 9 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.