Subnet calculator
- Network address
- 192.168.1.0
- Broadcast address
- 192.168.1.255
- First usable host
- 192.168.1.1
- Last usable host
- 192.168.1.254
- Usable hosts
- 254
- Total addresses
- 256
- Subnet mask
- 255.255.255.0
- Wildcard mask
- 0.0.0.255
- CIDR notation
- 192.168.1.0/24
- Address range
- 192.168.1.0 – 192.168.1.255
- Class
- C
- Scope
- Private (RFC 1918)
- Mask in binary
- 11111111.11111111.11111111.00000000
- Address in binary
- 11000000.10101000.00000001.00111001
- Subnets of /26
- 4
- Usable hosts in each
- 62
- Smallest block for 50 hosts
- /26
Calculated in your browser · nothing is looked up or uploaded
Give it any address and a prefix and it returns the network and broadcast addresses, the first and last usable host, the mask and wildcard, the total and usable counts, the class, the scope (public, private, loopback or carrier-grade NAT) and the address written out in binary. A /24 holds 256 addresses and 254 usable hosts. The panel opens on that and switches to five more jobs across the top: reading a dotted-decimal mask back as a prefix, rewriting an address as its 32-bit integer, in binary or in hexadecimal and back again, turning a start and end address into the smallest set of CIDR blocks, expanding or compressing an IPv6 address, and inventing MAC addresses that cannot collide with real hardware.
How to use the subnet calculator
A subnet mask is a run of ones followed by a run of zeros, and everything else follows from that. The ones mark the network part of the address and the zeros the host part, so ANDing an address with its mask gives the network address, and ORing it with the inverted mask gives the broadcast. That is the whole calculation; the rest is presentation.
The usable count is total minus two, because the all-zeros host is the network itself and the all-ones host is the broadcast. Two prefixes break that rule and both are common in real configurations. A /31 has no broadcast at all: RFC 3021 defines it as a point-to-point link with two usable addresses, which is why router-to-router links are configured that way and why a calculator reporting "0 usable hosts" for a /31 is wrong. A /32 is a single host; a host route rather than a network.
The prefix reads backwards the first hundred times: a longer prefix is a smaller network, because it counts network bits and leaves fewer for hosts. Each bit added halves the block, which is also why every count is a power of two and why you cannot have a network of exactly 300 addresses: you take a /23 and its 512, and use 300. CIDR replaced the fixed class boundaries in 1993 for precisely that reason: under classes, an organisation needing 300 addresses had to take a class B and waste 65,000 of them. The class row is still shown because people still say "a class C" when they mean a /24, and because the class sets the default mask on equipment old enough to care. It has had no effect on routing for thirty years.
A prefix must also be aligned to its own size. 10.0.1.0/23 is not a valid network, because a /23 has to start on an even third octet; equipment will usually reject it, and the containing network 10.0.0.0/23 is shown here instead. The same alignment rule is what makes a start-and-end range expensive to express in CIDR: 192.168.1.1 to 192.168.1.6 is six addresses and needs four blocks (192.168.1.1/32, 192.168.1.2/31, 192.168.1.4/31 and 192.168.1.6/32), because 1 is odd and can only start a /32. Take the largest aligned block that fits at the current address, move past it, repeat: that greedy walk is provably the smallest set, and the sizes sum to exactly the number of addresses between the two ends with nothing extra. The temptation is to round the whole thing up to one containing block instead, and in a firewall rule that grants access to every address the block covers beyond the range you meant. Ranges that begin and end on power-of-two boundaries collapse to a single block, which is a good argument for choosing them when you get to.
Only nine values can appear in a mask octet: 0, 128, 192, 224, 240, 248, 252, 254 and 255, one for each number of leading ones. Anything else is not a contiguous mask: 255.0.255.0 is the classic, and it is invalid because the network/host split has to be a single boundary rather than a scattered set of bits. Non-contiguous masks were briefly legal in the early internet and were removed because they make the longest-prefix match every router depends on impossible to do efficiently. The quickest check is to invert the mask and add one; a valid mask always gives a power of two.
That short list also turns the reverse direction, a dotted-decimal mask back to a prefix, into something you read off rather than compute, since each octet value stands for a fixed number of ones: 128 is 1, 192 is 2, 224 is 3, 240 is 4, 248 is 5, 252 is 6, 254 is 7, 255 is 8, and 0 is none. Add them up and you have the prefix. 255.255.240.0 is 8 + 8 + 4, so /20; 255.255.255.192 is 8 + 8 + 8 + 2, so /26. The two notations are the same boundary written twice, and equipment is split on which it wants: Linux and Cisco interface configuration take the mask, routing tables and firewall rules almost always take the prefix. The wildcard mask, which is the subnet mask inverted, is worth knowing separately, because Cisco access lists and OSPF take it instead of a subnet mask, and writing 255.255.255.0 where 0.0.0.255 belongs silently matches an entirely different set of addresses.
The scope row is the practically useful one. RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private use, and the middle block is where the mistakes live: it covers 172.16 through 172.31, not all of 172. Three more ranges answer questions people actually have. 169.254.0.0/16 is link-local, which a machine assigns itself when DHCP fails. Seeing one is a diagnosis rather than a configuration. 100.64.0.0/10 is carrier-grade NAT, which is why port forwarding does nothing on some connections and why a "public IP" you looked up may be unreachable. And 127.0.0.0/8 is all loopback, not just 127.0.0.1. Worth stating plainly, because the confusion is common: private is a routing property, not a security boundary. Anything on the same network reaches a private address freely.
The binary rows are there because that is how subnetting is actually taught, and for good reason: the mask is a boundary drawn through 32 bits, and it only looks arbitrary in decimal. 255.255.240.0 is unremarkable as a number and completely clear as twenty ones followed by twelve zeros. It is also the quickest way to check whether two addresses can talk without a router: mask both and compare the network halves. Underneath the dots the address is one 32-bit number: 192.168.1.1 is 3232235777, which is why databases holding IP data usually store the integer, since a subnet is then a contiguous span and "is this address in this network" becomes a comparison rather than string parsing. Sorting is the other reason: as text, "10.0.0.1" sorts before "9.0.0.1", and as an integer it does not.
Packing and unpacking that integer is two lines of arithmetic in either direction. To pack, a×16777216 + b×65536 + c×256 + d, which is what the binary row shows written out in bits. To unpack, shift right by 24, 16, 8 and 0 and mask each result with 255. The whole space is 0 to 4,294,967,295, or 0.0.0.0 to 255.255.255.255, and both ends are valid integers that are not hosts you can talk to. The integer, binary and hex mode does that round trip in both directions: one field takes whichever notation you have, says which one it decided it was, and prints the other three beside the in-addr.arpa name. Three traps come with the trip, and the mode is arranged around all three. A value stored in a signed 32-bit column cannot hold anything from 128.0.0.0 up and comes back negative; paste the negative straight in and it is recovered by adding 4,294,967,296, with a line saying that is what happened, because the column still wants to be unsigned or 64-bit. Byte order matters absolutely: reverse it and 192.168.1.1 becomes the perfectly valid 1.1.168.192, which is the classic endianness bug and never announces itself, which is why nothing here reorders bytes for you. And a leading zero is not decoration: 010.0.0.1 is 10.0.0.1 by the arithmetic above and 8.0.0.1 to the C library’s inet_aton, and two parsers disagreeing about that has been the root of real access-control bypasses. Rather than quietly become one of those two parsers, the panel refuses the string and says why. Reading four notations from one field creates one more ambiguity, settled the same way: digits alone are decimal, so 10101010 is 10,101,010 and not the eight hexadecimal digits it also happens to be, and hexadecimal with no letter in it has to carry its 0x. In hexadecimal the same address is padded to eight digits, two per octet, so 192.168.1.1 is C0A80101. MySQL exposes the conversion directly as INET_ATON and INET_NTOA; PostgreSQL has a native inet type that does the range arithmetic itself, so the integer round trip is rarely worth doing there.
Every row above is 32-bit arithmetic, so IPv6 is a different shape rather than a wider version of the same thing: 128 bits, written as eight groups of four hexadecimal digits, and no integer column will hold one. The written form has two rules and they cause most of the confusion. Leading zeros inside a group are dropped, so 2001:0db8:0000:0000:0000:0000:0000:0001 loses them; then the longest run of all-zero groups collapses to a single ::, giving 2001:db8::1. That double colon may appear only once, because two would leave no way to know how many groups each stood for, and when two runs are equally long the leftmost is the one that goes. A run of a single group is left alone, because :0: is already as short as ::. Expanding is the same rules backwards: count the groups you can see, and the :: stands for however many all-zero groups are missing from eight. The prefix works exactly as it does here, as a count of leading bits, but the sizes are fixed by convention rather than by arithmetic: a subnet is a /64 because stateless autoconfiguration needs 64 host bits, and an ISP hands out a /56 or /48 to be cut into /64s. There is no broadcast address at all, since multicast in ff00::/8 replaced it, and every interface carries a link-local fe80::/10 address whether anything was configured or not, which is the IPv6 counterpart of seeing a 169.254 address, except that here it is normal.
One implementation note that explains a lot of broken calculators. JavaScript’s bitwise operators return a signed 32-bit integer, so any address from 128.0.0.0 up comes back negative and prints as nonsense. Every value here is pushed back through an unsigned shift. If a subnet calculator gives you sensible answers for 10.x and garbage for 200.x, that is the bug, and the same signed-column mistake is why an address stored in a database sometimes comes back negative, recoverable by adding 4,294,967,296.
What people use it for
- Finding the network and broadcast address for a host
- Reading the usable host range of a block
- Seeing how many addresses a CIDR prefix holds
- Working out which network an address belongs to
- Converting a prefix length to its dotted-decimal mask and wildcard
- Reading an address and its mask lined up in binary
- Checking whether an address is public, private, loopback or reserved
- Catching a prefix that is not aligned to its own size, such as 10.0.1.0/23
- Splitting a block into smaller subnets
- Finding the smallest prefix that fits a given number of hosts
- Reading a dotted-decimal mask back as a prefix length
- Converting an address to the 32-bit integer a database column stores
- Turning a 32-bit integer back into a dotted-quad address
- Reading 32 binary digits back as an address, or writing one out in bits
- Reading an address as the eight hex digits a packet dump prints
- Recovering an address that a signed 32-bit column handed back negative
- Building the in-addr.arpa name for a reverse DNS record
- Turning a start and end address into the smallest set of CIDR blocks
- Expanding or compressing an IPv6 address
- Inventing MAC addresses for test data that cannot collide with real hardware
Questions
The all-zeros host is the network address and the all-ones host is the broadcast. Neither can be assigned to a machine.
255.255.255.0: twenty-four ones then eight zeros, giving 256 addresses and 254 usable hosts.
/24, because the prefix is simply a count of the leading ones. Any mask reads back the same way: add up what each octet is worth in ones, where 128 is 1, 192 is 2, 224 is 3, 240 is 4, 248 is 5, 252 is 6, 254 is 7, 255 is 8 and 0 is none. So 255.255.240.0 is 8 + 8 + 4, a /20, and 255.255.255.192 is 8 + 8 + 8 + 2, a /26.
The prefix counts network bits, so more of them leaves fewer bits for hosts and each one added halves the block. That is also why no block holds exactly 300 addresses: you take a /23, its 512, and use what you need. Under the old class system the same requirement forced a class B and wasted 65,000 addresses, which is the waste CIDR was introduced in 1993 to stop.
Not to routing; CIDR replaced them thirty years ago. They survive in conversation, where people say "a class C" and mean a /24, and in the default masks equipment old enough to care still assumes. The class row here is shown for reading old documentation, nothing more.
Only 0, 128, 192, 224, 240, 248, 252, 254 and 255, one for each number of leading ones. 255.0.255.0 is not a mask: it has ones on both sides of a zero run, so there is no single boundary. Non-contiguous masks were briefly legal in the early internet and were removed because they make longest-prefix matching impractical. The quickest check is to invert the mask and add one; a real mask always gives a power of two.
Cisco access lists and OSPF use it instead of a subnet mask. It is the mask inverted, and confusing the two matches the wrong addresses.
RFC 3021 defines a /31 as a point-to-point link with no broadcast, so both addresses are usable. It is how router-to-router links are configured. A /30 gives two as well, the classic four-address link, and a /32 is a single host route.
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The middle one covers 172.16 to 172.31 only, so 172.15 and 172.32 are public. Loopback is the whole of 127.0.0.0/8, not just 127.0.0.1, so 127.0.0.2 is loopback too.
DHCP failed and the machine assigned itself a link-local address. It is a fault report, not a setting.
Possibly carrier-grade NAT. An address from 100.64 to 100.127 means your ISP shares one real address between customers, so nothing outside can reach you directly.
No. It means not routable on the internet, which is a routing property. Anything on the same network reaches it freely.
Mask both and compare the network halves in the binary rows. If they match, no router is needed. The binary view is also why each octet stops at 255: it is one byte, and eight bits have no room for 256.
3232235777. Packing is a×16777216 + b×65536 + c×256 + d, and unpacking is the reverse: shift right by 24, 16, 8 and 0, masking each with 255. The whole space runs 0 to 4,294,967,295, which is 0.0.0.0 to 255.255.255.255. Databases store IP data that way because a subnet is then a contiguous span, and because "10.0.0.1" sorts before "9.0.0.1" as text and does not as a number. A negative value means a signed 32-bit column, which cannot hold anything from 128.0.0.0 up: add 4,294,967,296 to recover it and move the column to unsigned or 64-bit. The same signed result is why some subnet calculators are right for 10.x and nonsense for 200.x. The integer, binary and hex mode does the conversion both ways and takes a negative as read, so a value out of a signed column comes back as the address it was.
Paste it into the integer, binary and hex mode: the same field takes a dotted quad, a decimal integer, 32 binary digits with or without dots between the octets, and hexadecimal, and prints all four along with the in-addr.arpa name. It works out which notation you gave it and says so in the first row, because two of those overlap. Digits alone are read as decimal, so 10101010 is 10,101,010 and not the hexadecimal it also looks like; hexadecimal without a letter in it needs an 0x in front. And a negative is only ever a signed 32-bit column, so it is unwound rather than rejected.
Because two real parsers read it as two different addresses. This page treats each octet as decimal, so 010 is 10, while the C library’s inet_aton treats a leading zero as octal and makes it 8. Picking a side quietly is what makes a fetcher and a blocklist disagree, which is a working SSRF bypass, so the leading zero is refused and named instead. The same rule holds for a whole decimal number: 010 on its own is refused too. Fixed-width notations are exempt, since padding there has no second reading: 0x0000000A and 32 binary digits are both fine.
Because a block must be aligned to its own size. 192.168.1.1 to 192.168.1.6 takes four: a /32, two /31s and a /32, since 1 is odd and can only start a /32. Taking the largest aligned block that fits and repeating is provably the smallest set, and rounding up to one containing block would cover addresses outside the range, which in a firewall rule is access you did not intend to grant. The range mode does that walk for you: give it the two ends and it prints the blocks.
Drop the leading zeros inside each group, then collapse the longest run of all-zero groups to a single ::, so 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1. The :: can appear only once, because two would leave no way to know how many groups each stood for, and the leftmost run wins when two are the same length. Expanding reverses it: the :: stands for however many all-zero groups are missing from eight. A subnet is a /64 because stateless autoconfiguration needs 64 host bits, and an ISP hands out a /56 or /48 to be cut into /64s. There is no broadcast address at all; multicast in ff00::/8 replaced it, and every interface carries a link-local fe80:: address whether anything was configured or not. The subnet rows are 32-bit IPv4 arithmetic and none of it applies to a 128-bit address, so the IPv6 mode does the two written rules and the scope, and stops there.
No. It is arithmetic on the address you type; nothing is queried and nothing leaves your browser, which is why it works on an internal network with no connectivity.