0

If a host has IP 192.168.20.150 with DHCP server say 192.168.20.10, how does the host know the bounds of the subnet? is this where proper network subnetting comes in?

To clarify... the DHCP server hands out for example:
IP: 192.168.20.150
Subnet: 255.255.254.0
Gateway: 192.168.20.10
DHCP Server: 192.168.20.10

My question is: how does the host know if the subnet host range is 192.168.20.1 - 192.168.21.254 or 192.168.19.1 - 192.168.20.254.

I have put this into subnet-calculator.com and it seems to have set the third octet as being even, which I think clarifies in this example. Wasn't sure of the rule

phaseform
  • 1
  • 1
  • There is a section in this two-part answer that explains exactly your question. – Ron Maupin Mar 17 '19 at 15:42
  • Again, there is a section in this two-part answer that explains exactly your question. This is an extremely basic addressing question. Simply mask the address with the network mask to get the network, and mask the address with the host mask to get the network broadcast address. All the addresses between are the usable host addresses. How a host determines if a destination is on the same network is clearly explained in the answer. – Ron Maupin Mar 17 '19 at 21:36
  • 1
    By the way, octets have nothing to do with it. The octets are simply to make it easier for humans to read IPv4 addresses. Trying to do it in decimal with the octets will lead to mistakes. You must do IPv4 math in binary. – Ron Maupin Mar 17 '19 at 21:38
  • Perfectly answers the question, thank you for such an informative post! – phaseform Mar 17 '19 at 22:00

1 Answers1

3

In addition to the client IPv4 address, a DHCP server can offer a number of options. Nearly always included are subnet mask (0x01), router (0x03), domain name server (0x06).

The subnet mask defines the size of the local subnet. It defines how many bits belong to the subnet address aka prefix. The rest of the 32-bit IP address is used for host-specific addresses. If the subnet mask isn't configured by DHCP it needs to be configured locally.

The size of the local subnet is important for a client. Destinations inside the local subnet can be talked to directly - commonly using Ethernet L2 frames. Destinations outside the local subnet require the use of a gateway aka router.

All bits in the host-specific part set to 1 is the directed broadcast address of the subnet (e.g. x.y.z.255 for the x.y.z.0/24 subnet). A limited broadcast is simpler, it's always 255.255.255.255. It has the same reach as a directed broadcast but is generally not forwarded across routers.

Broadcast domain is a term used for the reach of a layer-2 network. That domain is limited by the physical and logical connections in a network (e.g. all ports connected to a switch, interconnected switches or a VLAN).

An IP broadcast uses the layer-2 broadcast mechanism for delivery and usually has the exact same size, sometimes they do differ.

Zac67
  • 84,333
  • 4
  • 69
  • 133