imbizcorp

Understanding network infrastructure · Part 1 · How does my PC get ready to communicate?

How does my PC know if a destination is on the same network?

Using a 32-bit address and prefix to decide whether ARP should look for the host or the gateway

BY IM Business Platform Co., Ltd. PUB 2026-08-18 UPD 2026-10-26 READ About 10 min VERIFY Standards and official sources

Before an endpoint sends a packet, it determines whether the destination IP is on its own network. It applies its subnet mask to both its own and the destination IP address, compares the resulting network addresses, then looks up either the destination host's or the default gateway's MAC address. We follow the actual 32-bit values and AND operations to see how that decision changes the first frame's destination MAC.

Expand an IPv4 address into bits to see the network boundary↑

We write 192.0.2.34 as four numbers separated by dots, but a device processes it as a 32-bit value. Each number represents an eight-bit octet, ranging from 0 to 255. Dotted notation is for people to read; bit positions define the network boundary.

An address alone does not show where its network portion ends. A /24 prefix, or 255.255.255.0 subnet mask, tells you that the first 24 bits form the network portion.

For example, in 192.0.2.130, the last octet 130 is 10000010 in binary. With a /25 prefix, the first bit of that last octet belongs to the network; the remaining 7 bits are the host portion. Thus, 192.0.2.130/25 belongs to 192.0.2.128/25. The prefix boundary in the bits determines network membership, not the appearance of the dotted numbers.

Interpret the same address with /24 and its network address is 192.0.2.0; with /26, it is 192.0.2.128. This is why comparing IP addresses alone cannot tell you whether two endpoints are on-link. Always record the address and prefix together in configurations and incident records. Writing only 192.0.2.130 leaves out half the information needed for forwarding. In router and host route output, read the address and its prefix as one value.

The network-at-the-front, host-at-the-back explanation looks straightforward only when the prefix boundary falls between octets. With a boundary inside an octet, as in /27, the last octet itself contains both network and host bits. Read the full 32 bits with the prefix length instead of relying on the dotted numbers. Record the address and prefix as a pair when documenting calculations too.

Sources for this section IETF RFC 791 · IETF RFC 4632

Reading the diagram The four octets of the IPv4 address 192.168.10.15 are expanded into 32 bits. Compare each octet's binary digits with the positional weights shown as powers of two to see how they produce the decimal address value.

↔ Scroll horizontally to explore the diagram.

Figure 1. 192.168.10.15 as 32 bits: octets and bit weightsThe four octets (192, 168, 10, 15) are each expanded into eight bits. Their positional weights halve from 2^7 (128) to 2^0 (1).[Figure 1] 192.168.10.15 as 32 bits: octets and bit weights1st Octet: 192110000002nd Octet: 168101010003rd Octet: 10000010104th Octet: 1500001111Bit weights in an 8-bit octet:2^7(128) | 2^6(64) | 2^5(32) | 2^4(16) | 2^3(8) | 2^2(4) | 2^1(2) | 2^0(1) The four octets (192, 168, 10, 15) are each expanded into eight bits. Their positional weights halve from 2^7 (128) to 2^0 (1).

Endpoints AND their IP addresses with their subnet masks to identify their networks↑

The endpoint combines its address and mask with bitwise AND. Where the mask has a 1, the address bit is retained; where it has a 0, the result is 0.

My address 192.0.2.34    /24
Mask 255.255.255.0
AND result 192.0.2.0     ← My network

Apply the same operation to the destination and compare the results. With the same prefix length, matching network addresses indicate an on-link destination; different results indicate a remote one.

For 192.0.2.130/26, the mask is 255.255.255.192. In the last octet, 130 is 10000010, and the mask value 192 is 11000000. AND them to get 10000000, or 128, making the network address 192.0.2.128. Destination 192.0.2.190 gives the same result, but 192.0.2.200 gives 192.0.2.192.

The operating system uses this calculation to install a connected route for destination lookups. You do not calculate binary values for every packet, but the route entry 192.0.2.128/26 reflects that calculation. During troubleshooting, do more than verify the arithmetic: check that the actual interface prefix and connected route cover the same range. That confirms whether the setting is reflected in forwarding behavior.

The route table may contain this directly connected prefix, more-specific routes, and a default route. Prefix comparison is a useful starting point for explaining a host's decision, but prefix comparison alone is not the whole story. Policy routing, a VPN, or a host route can affect the actual transmission. Check the final route lookup too.

Sources for this section IETF RFC 1122 · IETF RFC 4632

Reading the diagram Compare the host IP address 192.168.10.130 with the /26 subnet mask: their bitwise AND produces network ID 192.168.10.128. Read the last octet of the address, mask, and result side by side to identify the network bits and the 192.168.10.128–191 range.

↔ Scroll horizontally to explore the diagram.

Figure 2. Bitwise AND produces the network address (network ID)AND host IP 192.168.10.130 with the /26 mask (255.255.255.192) to get network address 192.168.10.128. The upper 2 bits of the last octet belong to the network, placing the host within 192.168.10.128~191.[Figure 2] Bitwise AND produces the network address (network ID)Host IP: 192.168.10.13011000000 . 10101000 . 00001010 . 10000010Subnet Mask: /26 (255.255.255.192)11111111 . 11111111 . 11111111 . 11000000Calculated Net ID: 192.168.10.12811000000 . 10101000 . 00001010 . 10000000In the mask's last octet (11000000), the upper 2 bits belong to the network.192.168.10.130 is a host within [192.168.10.128 ~ 191]. AND host IP 192.168.10.130 with the /26 mask (255.255.255.192) to get network address 192.168.10.128. The upper 2 bits of the last octet belong to the network, placing the host within 192.168.10.128~191.

For a local destination, the endpoint looks up the host's MAC directly↑

Destination 192.0.2.80, with a /24 mask applied, yields 192.0.2.0. This matches my network, so the endpoint uses ARP to ask for 192.0.2.80's MAC address.

After the reply arrives, the Ethernet destination is set to that MAC address, while the IP destination remains 192.0.2.80. The switch uses its MAC address table to send the frame through the appropriate port.

When the endpoint considers 192.0.2.80 on-link, it puts that address in the ARP request's target IP field and sends a broadcast frame. After the reply, the data frame's destination MAC belongs to the 192.0.2.80 NIC—its MAC address. The default gateway is not involved. For same-subnet communication, it may therefore be normal to find nothing in the gateway ACL or a router capture.

Without an ARP reply, the endpoint cannot fill in the frame's destination MAC address. What looks like an application connection timeout may actually be a failure before TCP can connect. Check the ARP cache for incomplete state and repeated requests, along with the switch's VLAN and where it learned the MAC address. Even if the address calculation places both devices on one network, a broken link or powered-off peer prevents communication.

A missing ARP reply does not by itself mean the switch is faulty. The other host may be off or in a different VLAN, or the endpoint's wrong mask may make a remote address appear local. First check whether ARP is asking about the right device; that separates a Layer 2 problem from an address-classification error. Save a route lookup taken at the same time so you can verify the decision again.

Sources for this section IETF RFC 1122 · IETF RFC 826

For a remote destination, why skip the server and look up the gateway's MAC address?↑

For 198.51.100.20/24, the network result is 198.51.100.0, different from the local prefix. The endpoint does not look for the server's MAC address. It queries the configured default gateway, 192.0.2.1, for its MAC address using ARP.

Ethernet destination Gateway MAC
IP destination 198.51.100.20

The gateway receives the frame, removes the old Layer 2 header, and looks up a route for the IP destination. For the next link, it creates a new Layer 2 header and forwards the packet.

Even if the remote server is several routers away, the client needs only one MAC address: that of its first gateway. The client keeps the IP packet's destination at 198.51.100.20, while the Ethernet destination is 192.0.2.1's MAC address. The gateway recognizes its own MAC address in the frame, removes the Layer 2 header, and uses the IP destination for a route lookup. The next link gets different source and destination MAC addresses in a new frame.

It is therefore normal for the remote server's MAC address to be absent from the client ARP cache. If a remote server IP triggers repeated ARP requests, suspect the client's mask or an on-link route. Even after the gateway MAC is learned successfully, the gateway may lack an onward route: an ICMP unreachable may return, or the packet may be dropped. Successful ARP is evidence of preparation for the first hop, not end-to-end reachability.

The distinction illustrates a central rule: the IP address identifies the end-to-end destination, while the MAC address identifies the next receiving device on the current link. Each router replaces source and destination MAC addresses for the new link and reduces the TTL. In ordinary routing, the final IP destination stays unchanged unless a separate function such as NAT intervenes.

Sources for this section IETF RFC 1122 · IETF RFC 826

Reading the diagram Apply the same mask to source and destination, then compare the two network IDs. Follow the on-link and off-link branches to the ARP target and Layer 2 destination MAC. The local destination is 192.168.10.42; the next forwarding target for the remote destination is gateway 192.168.10.1. Use the two frame boxes below to distinguish the final destination IP from the destination MAC on the current link.

↔ Scroll horizontally to explore the diagram.

Figure 3. On-link or off-link? Compare AND results and ARP targets The 192.168.10.15/26 endpoint applies the same mask to two destinations and compares network IDs. It uses ARP for the destination host when on-link, or the default gateway when off-link. [Figure 3. On-link or off-link? Compare AND results and ARP targets] Input Host = 192.168.10.15/26 Mask = 255.255.255.192 Destination A = 192.168.10.42 Destination B = 192.168.10.130 1. Host Network ID 192.168.10.15 AND 255.255.255.192 (/26) = 192.168.10.0 Connected prefix in the local routing table 2A. Destination A Network ID 192.168.10.42 AND /26 = 192.168.10.0 → On-link ARP Target IP = 192.168.10.42 Ethernet Dst = Host A's MAC 2B. Destination B Network ID 192.168.10.130 AND /26 = 192.168.10.128 → Off-link Route Lookup → Default Gateway 192.168.10.1 ARP Target IP = 192.168.10.1 On-link Frame L2 Dst MAC = 192.168.10.42's MAC · L3 Dst IP = 192.168.10.42 Off-link Frame L2 Dst MAC = Gateway MAC · L3 Dst IP = 192.168.10.130 (unchanged) Off-link: IP Destination remains the final host; only this link's Ethernet Destination becomes the gateway MAC.

Subnet mask errors can make the same device look local to one host and remote to another↑

An endpoint and gateway may appear to share an IP range, yet different masks can produce different decisions. If the endpoint's mask makes the local range too broad, it may treat an address beyond a router as local and repeatedly send unanswered ARP requests.

If the mask makes the local range too narrow, a destination actually in the same subnet may be treated as external and sent to the gateway. The frame is then addressed to the gateway's own MAC address. Further delivery depends on the gateway's routes and policies. Taking an already received packet and routing it onward is not proxy ARP.

For example, one side using /24 and the other /25 may classify the same two addresses differently. The side with the broader local range may send ARP directly for the destination; the other may send to the gateway. A remote-address ARP request answered on the destination's behalf by a router is proxy ARP, which can hide a mask error. That differs from a gateway recognizing its own MAC address in a received frame and routing the enclosed packet.

To investigate a mask error, inspect both endpoints. A successful ping from one side, or communication that happens to work through a gateway, does not prove the configuration is correct. On both sides, look up the peer's IP route and compare the ARP targets. Check DHCP options against manual settings. After correcting the mask, refresh the existing ARP and route caches and retest the new decisions.

Within one VLAN, two hosts with different masks can show asymmetric symptoms, with communication succeeding in only one direction. A may see B as on-link and send directly, while B sees A as off-link and sends to the gateway. Compare both hosts' addresses, prefixes, routes, and the actual ARP target IP addresses.

Sources for this section IETF RFC 1122 · IETF RFC 4632

Connection failing? Compare the endpoint's ARP target and route lookup↑

Scenario: The 192.0.2.34 endpoint cannot connect within the same VLAN to the 192.0.2.130 server.

  1. Check both endpoints' prefixes. Does one use /25 and the other /24?
  2. Capture each endpoint's choice between the peer and the gateway as its ARP target.
  3. Check the local route and default route, including their installed prefixes.
  4. Align the DHCP options and manually configured masks with the same design values.
  5. Refresh the ARP cache, then retest communication in both directions and the return path.

Start with the operating system's route lookup. Does destination 192.0.2.130 match a connected route or use the default route? Next, inspect the actual ARP target IP in the capture: the peer or the gateway? If the calculated branch and observed packets disagree, look for a more-specific host route, a VPN route, or policy routing that takes precedence over the basic interface prefix.

Do not stop at temporarily widening one endpoint's mask. Align the VLAN design prefix, gateway interface, DHCP scope, static host settings, and network monitoring targets. Then test between two endpoints in the same subnet and toward a destination in another subnet. Together, those tests confirm that local ARP and gateway forwarding follow the intended branches again.

The key question is not simply why ping failed. It is whose MAC address the endpoint looked for and whether that choice matched the address plan. That understanding also connects subnet size calculations to the actual forwarding range.

Sources for this section IETF RFC 1122 · IETF RFC 826

Glossary↑

Sources and verification

  1. IETF RFC 791 — basic IPv4 addressing and header specification
  2. IETF RFC 1122 — host requirements for subnets and gateways
  3. IETF RFC 4632 — CIDR prefixes and address aggregation
  4. IETF RFC 826 — IPv4 ARP operation

The IPv4 examples use RFC 5737 documentation ranges and RFC 1918 private address space. Operating-system on-link route notation and default proxy ARP behavior may vary by implementation.