What is a subnet? Subnet masks and CIDR notation explained
By the ProxyOnly team · 16 Nov 2026 · 5 min read
A subnet is a block of addresses that share the same beginning. How masks and CIDR notation work, how to split and check ranges, and why ranges matter for proxies.
A subnet is a block of consecutive IP addresses that share the same beginning, so that a network can treat them as one group. You meet subnets as notation such as 192.168.1.0/24, in your router's settings, in cloud networks and in the lists of ranges that internet providers and blocklists publish. The notation looks like arithmetic, and it is, but only a little of it. This article explains it with examples that we ran in Python, so that you can check every number yourself. If addresses themselves are new to you, start with what is an IP address.
A network part and a host part
An IPv4 address has 32 bits. A subnet fixes the first bits, called the network part, and leaves the rest free to vary, called the host part. Every address in the subnet shares the same network part. The subnet mask records which bits are fixed: a 1 marks a network bit and a 0 marks a host bit.
The mask 255.255.255.0 is 24 ones followed by 8 zeros. We asked Python to show it for 192.168.1.0/24:
import ipaddress
net = ipaddress.ip_network("192.168.1.0/24")
print("mask ", net.netmask, "=", bin(int(net.netmask))[2:].zfill(32))
print("broadcast ", net.broadcast_address)
print("addresses ", net.num_addresses)
hosts = list(net.hosts())
print("usable ", len(hosts), "from", hosts[0], "to", hosts[-1])It printed:
mask 255.255.255.0 = 11111111111111111111111100000000
broadcast 192.168.1.255
addresses 256
usable 254 from 192.168.1.1 to 192.168.1.254CIDR notation
The /24 is CIDR notation. It simply counts the network bits, so /24 means that the first 24 bits are fixed and 8 bits are free. The number of addresses in the block is 2 to the power of the free bits. With 8 free bits that is 256.
CIDR stands for Classless Inter-Domain Routing and is defined in RFC 4632. It replaced the older system of fixed classes. In that system a Class A network had 16,777,216 addresses, a Class B network had 65,536, and a Class C network had 256, with nothing in between. CIDR lets a block have any power-of-two size, which made it possible to hand out addresses without wasting most of a block.
Each extra bit in the prefix halves the block. We listed common sizes:
for prefix in (8, 16, 20, 24, 26, 28, 30, 31, 32):
n = ipaddress.ip_network(f"10.0.0.0/{prefix}")
print(f"/{prefix:<4} {str(n.netmask):16} {n.num_addresses:>10,}")/8 255.0.0.0 16,777,216
/16 255.255.0.0 65,536
/20 255.255.240.0 4,096
/24 255.255.255.0 256
/26 255.255.255.192 64
/28 255.255.255.240 16
/30 255.255.255.252 4
/31 255.255.255.254 2
/32 255.255.255.255 1How many addresses can you use?
In an ordinary subnet the first address is the network address, which names the block, and the last is the broadcast address, which reaches every device in it. Neither goes to a device, so a /24 has 254 usable addresses, as the output above shows. There are two exceptions. A /31 has two addresses and, under RFC 3021, both can be used on a point-to-point link. A /32 is a single address, which is how you write one machine in a firewall rule or a route.
Cloud networks reserve more. Amazon's documentation says that the first four addresses and the last address of every subnet in a VPC are not available, so in 10.0.0.0/24 five addresses are reserved. The smallest subnet it allows is a /28, which has 16 addresses and leaves 11 for your own use.
Splitting, checking and merging
You can cut a block into smaller ones by adding bits to the prefix. We split a /24 into four /26 blocks, asked whether two addresses fall inside 192.168.1.64/26, found the /24 that contains an address, and merged two neighbouring blocks:
net = ipaddress.ip_network("192.168.1.0/24")
for sub in net.subnets(new_prefix=26):
print(sub, sub[0], "to", sub[-1])
print(ipaddress.ip_address("192.168.1.77") in ipaddress.ip_network("192.168.1.64/26"))
print(ipaddress.ip_address("192.168.1.200") in ipaddress.ip_network("192.168.1.64/26"))
print(ipaddress.ip_network("203.0.113.57/24", strict=False))
print(list(ipaddress.collapse_addresses([ipaddress.ip_network("198.51.100.0/24"), ipaddress.ip_network("198.51.101.0/24")])))192.168.1.0/26 192.168.1.0 to 192.168.1.63
192.168.1.64/26 192.168.1.64 to 192.168.1.127
192.168.1.128/26 192.168.1.128 to 192.168.1.191
192.168.1.192/26 192.168.1.192 to 192.168.1.255
True
False
203.0.113.0/24
[IPv4Network('198.51.100.0/23')]The last two lines show that a /24 that contains 203.0.113.57 is 203.0.113.0/24, and that two neighbouring /24 blocks can merge into a /23. Blocks merge only when they line up, so 198.51.100.0/24 and 198.51.101.0/24 merge, and 198.51.101.0/24 and 198.51.102.0/24 do not.
You can check membership by hand too. Apply the mask to the address with a bitwise AND, and compare the result with the network address. For 192.168.1.77 and the mask 255.255.255.192, the last number is 77, which is 01001101 in binary. The mask's last number is 192, which is 11000000. The AND is 01000000, which is 64. The result is 192.168.1.64, the network address, so the address is inside.
How routers use prefixes
A router keeps a table of prefixes and where to send traffic for each. When several prefixes match an address, the most specific one, the one with the longest prefix, wins. We wrote a four-line table and tested it:
routes = {"0.0.0.0/0": "default gateway", "10.0.0.0/8": "office VPN", "10.1.0.0/16": "datacenter A", "10.1.2.0/24": "rack 7"}
def pick(ip):
ip = ipaddress.ip_address(ip)
matches = [(ipaddress.ip_network(n), via) for n, via in routes.items() if ip in ipaddress.ip_network(n)]
return max(matches, key=lambda m: m[0].prefixlen)
for ip in ["10.1.2.77", "10.1.9.5", "10.200.0.1", "8.8.8.8"]:
net, via = pick(ip)
print(f"{ip:11} -> {str(net):12} {via}")10.1.2.77 -> 10.1.2.0/24 rack 7
10.1.9.5 -> 10.1.0.0/16 datacenter A
10.200.0.1 -> 10.0.0.0/8 office VPN
8.8.8.8 -> 0.0.0.0/0 default gatewayThe address 10.1.2.77 matches all four routes, and the /24 wins. The route 0.0.0.0/0 matches everything, which is why it is called the default route.
IPv6 subnets
IPv6 uses the same notation with 128 bits. A standard subnet is a /64, because RFC 4291 requires the interface identifier of most unicast addresses to be 64 bits long. A single /64 holds 18,446,744,073,709,551,616 addresses, according to Python, so nobody counts hosts in an IPv6 subnet the way they do in IPv4.
Why ranges matter when you use proxies
Blocklists work on ranges. The Spamhaus DROP lists, for example, consist of netblocks, not single addresses. Addresses that sit next to each other can therefore share a fate, because a provider or a site may judge a whole range by the worst behaviour in it.
When you buy several proxy addresses, count how many different ranges they come from. We checked a list of six addresses with Python:
ips = ["203.0.113.10", "203.0.113.11", "203.0.113.200", "198.51.100.7", "198.51.100.8", "192.0.2.50"]
ranges = {ipaddress.ip_network(f"{ip}/24", strict=False) for ip in ips}
print(len(ips), "addresses sit in", len(ranges), "different /24 ranges")It printed 6 addresses sit in 3 different /24 ranges. A pack inside one /24 can be affected together, and a pack spread over many ranges is less likely to be. It is a fair question for any provider, and how to evaluate a proxy provider lists others.
The range also shows who owns the addresses. What is an ASN explains how that decides whether a site sees a hosting company or a home connection.
Try it yourself
- How many usable addresses does a
/27have? A/27has 32 addresses, and two of them are the network and broadcast addresses, so the answer is 30. - Which
/24contains172.16.45.9? The answer is172.16.45.0/24. - Is
10.0.3.5inside10.0.0.0/22? A/22has 1,024 addresses, so it covers10.0.0.0to10.0.3.255, and the answer is yes.
You can confirm each answer with the snippets above.
Try it yourself
Create an account, add funds from US$1 and order a proxy in the country you need.
Keep reading
16 Nov 2026 · IP addresses and privacy
Proxies, privacy and the law: a responsible-use guide
Whether using a proxy is legal, what computer misuse and data protection law say, what your provider can see about you, and a checklist for using proxies responsibly.
16 Nov 2026 · IP addresses and privacy
How to change or hide your IP address: the options compared
Seven ways to change or hide your IP address compared by what each one hides, from whom, and what it leaves exposed, with a way to check that it worked.