---
title: Why can't my server reach the gateway? How to calculate a subnet with the Subnet Calculator
description: A freshly configured server reaches some machines on its LAN but not the gateway or the printer down the hall. Very often the subnet mask is wrong. To calculate a subnet, apply the mask to the address: you get the network address, the broadcast address and the range of hosts that are on-link. Here's how to do it in one step with the free Subnet Calculator, how to read every field, and a Python one-liner that gives the same answer.
canonical: https://watchfor.io/blog/how-to-calculate-a-subnet
---

# Why can't my server reach the gateway? How to calculate a subnet with the Subnet Calculator

2026-10-04 · WatchFor Team · Guides · guides, networking, basics

A freshly configured server reaches some machines on its LAN but not the gateway or the printer down the hall. Very often the subnet mask is wrong. To calculate a subnet, apply the mask to the address: you get the network address, the broadcast address and the range of hosts that are on-link. Here's how to do it in one step with the free Subnet Calculator, how to read every field, and a Python one-liner that gives the same answer.

To calculate a subnet, apply the subnet mask to the IP address. The bits the
mask covers give the **network address**. Setting all the remaining host bits
to 1 gives the **broadcast address**, and everything in between is the
usable **host range**. `192.168.10.77/26` (mask `255.255.255.192`) sits in
`192.168.10.64`–`192.168.10.127`, with hosts `.65` to `.126`. A machine
only talks directly to addresses inside that range. Anything else, including
a gateway outside it, needs a router.

The free [Subnet Calculator](/subnet-calculator) does that arithmetic as you
type: network, broadcast, usable range, subnet and wildcard masks, host
count, the address type, and in Advanced mode the binary breakdown and a
subnet splitter. It runs in your browser; nothing is sent anywhere.

## What this tool answers

*Which addresses belong to this subnet, and is that other address one of
them?* Reach for it when two machines that should talk can't, when you
configure a static IP and need the mask and gateway right, when you plan
VLANs or cloud subnets, or when a firewall wants a dotted mask or a Cisco
wildcard instead of a prefix length.

## A real example

### Calculating a subnet to see if two hosts are on the same network

A typical support ticket: a new server was given a static address. It can
ping a few machines on the LAN, but not the default gateway `192.168.10.1`,
not the printer at `192.168.10.130`, and nothing on the internet. The
configuration says address `192.168.10.77`, mask `255.255.255.192`.

In the [Subnet Calculator](/subnet-calculator) we pasted `192.168.10.77/26`
(255.255.255.192 is /26; pasting the CIDR moves the prefix into the selector)
and switched to **Advanced**:

![The Subnet Calculator for 192.168.10.77/26 in Advanced mode: summary 192.168.10.64/26 with 62 usable hosts from 192.168.10.65 to 192.168.10.126, network address 192.168.10.64, broadcast 192.168.10.127, subnet mask 255.255.255.192, wildcard mask 0.0.0.63, 64 total and 62 usable addresses, and the binary breakdown with 26 network bits and 6 host bits](/blog/how-to-calculate-a-subnet-result.webp)

The calculator puts the server in **192.168.10.64/26**: network
`192.168.10.64`, broadcast `192.168.10.127`, usable hosts `.65`–`.126`, 62 in
total. The binary breakdown shows why: the last octet of `.77` is `01001101`,
and with 26 network bits only its last six bits (`001101`) are host bits.

Neither the gateway (`.1`) nor the printer (`.130`) is in that range. To the
server, both are on some other network, reachable only through a router. Its
only router is `.1`, which it can't reach directly either, so the default
route is unusable. The machines it *could* ping were the ones between `.65`
and `.126`.

**The answer:** the mask was wrong. The office LAN is a /24. Typing
`192.168.10.77/24` into the calculator gives network `192.168.10.0`,
broadcast `192.168.10.255` and 254 usable hosts, which includes the gateway
and the printer. Setting the mask to `255.255.255.0` fixed everything. The
rule to remember: **every host on one segment must use the same network and
mask, and the gateway must sit inside that range**.

## How to read the results

| Field | What it means |
| --- | --- |
| **Summary (e.g. 192.168.10.64/26)** | The subnet the address belongs to, in CIDR form, with the usable range. The arrows step to the previous or next subnet of the same size. |
| **Type badge** | Private (RFC 1918), Public, CGNAT (`100.64.0.0/10`), Loopback, Link-local and so on. |
| **Network address** | The first address: identifies the subnet itself, not assignable to a host. |
| **Broadcast address** | The last address: a packet sent here reaches every host on the subnet. Not assignable either. |
| **Usable host range** | The addresses you can give to machines. A /31 is the point-to-point exception: both addresses usable (RFC 3021). |
| **Subnet mask** | The prefix written as dotted decimal, e.g. /26 = `255.255.255.192`. What most OS network dialogs ask for. |
| **Wildcard mask** | The mask inverted, `0.0.0.63` for /26. Cisco ACLs and OSPF use it. |
| **Addresses** | Total addresses in the block and how many are usable (total minus 2, above /31). |
| **Binary breakdown** (Advanced) | Address, mask and network in bits, network bits in blue and host bits in green. The quickest way to see where the boundary falls. |
| **IP class, Integer, Hex, PTR record** (Advanced) | The legacy class (A/B/C), the address as a 32-bit number and in hex, and the `in-addr.arpa` name used for its reverse DNS. |
| **Subnet splitter** (Advanced) | Carves the block into equal smaller subnets and lists each one's network, range and broadcast. |

## More ways to use it

- **Before setting a static IP.** Check the address, mask and gateway
  together: the gateway must appear inside the usable range.
- **Planning VLANs.** Start from your block (say `10.20.0.0/22`), pick a
  smaller prefix in the splitter, and give each VLAN one row.
- **Cloud subnets.** Size them with headroom: AWS reserves the first four
  addresses and the last one in every VPC subnet, so a /28 gives 11 usable
  addresses, not 14.
- **Reading someone else's config.** A firewall rule with
  `192.168.10.64 0.0.0.63` or a route to `10.1.4.0/23`: paste it in to see
  exactly what it covers. For ranges and allowlists, the
  [CIDR guide](/blog/how-to-calculate-cidr-ranges) goes further.
- **Reverse DNS zones.** The PTR record field gives the `in-addr.arpa` name
  for an address, which is what your DNS provider asks for when you set up
  [reverse DNS](/reverse-dns-lookup).

## Tips and gotchas

- **Mismatched masks fail half-way.** Two hosts with different masks can
  sometimes reach each other in one direction only, or only for some
  addresses. If connectivity is partial, compare masks first.
- **The usable count is total minus two.** A /24 has 256 addresses and 254
  usable hosts; a /30 has 4 and 2. A /31 (2 usable, point-to-point) and a
  /32 (one host) are the exceptions.
- **Overlapping subnets break VPNs.** If home and office both use
  `192.168.1.0/24`, traffic for the office never leaves your house. Check
  ranges before connecting networks.
- **The default gateway isn't always `.1`.** It's convention, not a rule.
  The only rule is that it's inside the subnet.
- **IPv6 is different.** LANs are always /64 there, and there's no
  broadcast address. Use the [IPv6 Subnet Calculator](/ipv6-subnet-calculator)
  and the [IPv6 planning guide](/blog/how-to-plan-ipv6-subnets).

## Check it from the command line too

Python's standard library has the same arithmetic, so it works anywhere
Python 3 is installed:

```bash
python3 -c "
n = ip.ip_interface('192.168.10.77/26').network
print(n, n.netmask, n.broadcast_address, n.num_addresses - 2)
print(ip.ip_address('192.168.10.1') in n, ip.ip_address('192.168.10.130') in n)"
```

```text
192.168.10.64/26 255.255.255.192 192.168.10.127 62
False False
```

The same network, mask, broadcast and host count as the calculator, and
`False False`: neither the gateway nor the printer is inside. With `/24`
instead:

```text
192.168.10.0/24 255.255.255.0 192.168.10.255 254
```

On the machine itself, `ip -4 addr` (Linux) or `ipconfig` (Windows) shows the
address and prefix it actually uses; `ip route` shows whether a default
route exists and through which gateway.

## FAQ

**How do I find my subnet mask?**
On Windows, `ipconfig` lists it as *Subnet Mask*. On Linux and macOS, `ip addr`
or `ifconfig` shows it as a prefix (`/24`) or a hex mask. Paste address and
prefix into the calculator to see the whole subnet.

**How many hosts are in a /24, /26 or /28?**
254, 62 and 14 usable hosts: 2 to the power of the host bits, minus the network
and broadcast addresses. The [CIDR calculator](/cidr-calculator) lists any
prefix.

**What is the difference between a subnet mask and CIDR?**
They express the same thing two ways: `/26` and `255.255.255.192` both mean 26
network bits. CIDR is the shorter notation.
[What is an IP address?](/blog/what-is-an-ip-address) covers the basics, and
[NAT explained](/blog/nat-explained) how private subnets reach the internet.

---

Canonical page: https://watchfor.io/blog/how-to-calculate-a-subnet · All articles: https://watchfor.io/blog/all.md · Site guide: https://watchfor.io/llms.txt
