Utilities

IPv4 Calculator

Calculate an IPv4 network, mask and address range.

Processed in your browser

The IPv4 Calculator takes an address with a prefix length, written in CIDR notation such as 192.168.1.0/24, and works out the network that address belongs to. It shows the network address, the subnet mask, the wildcard mask, the broadcast address, the first and last addresses a device can use, and how many addresses the network holds.

The calculation runs in your browser. The page shows "Processed in your browser", and the address you type is not sent to the IP Tracker server. No connection is made to the address either, so private ranges such as 10.0.0.0/8 can be entered like any other.

Each row comes from a few operations on 32 bits, and you can do them by hand once you have seen them. For the planning side, meaning how large a network should be for a number of devices, see Subnet Calculator, which runs the same calculation.

How to use the calculator

  1. Type an IPv4 address, a slash and a prefix length into the field, for example 192.168.1.0/24.
  2. Click Calculate.
  3. Read the rows of the result. Network and Broadcast mark the two ends of the range, and the usable addresses lie between them.
  4. To keep the result, open "View as JSON" under the rows, or use Copy JSON and Download JSON.

You do not have to enter the network address itself. Any address inside the network gives the same answer, so 192.168.1.57/24 and 192.168.1.0/24 both report the network 192.168.1.0/24. That helps when all you have is the address and mask of one device.

The prefix has to be a number after a slash. If it is missing, or if a dotted mask such as 255.255.255.0 stands in its place, the page shows "Use IPv4 CIDR notation, for example 192.168.1.0/24."

How to read the result

RowWhat it showsValue for 192.168.1.0/24
NetworkThe first address of the range, written with the prefix. It names the network as a whole192.168.1.0/24
Subnet maskThe prefix length written as four numbers255.255.255.0
Wildcard maskThe subnet mask with every bit flipped0.0.0.255
BroadcastThe last address of the range, which reaches every device in the network192.168.1.255
First usableThe lowest address you can give to a device192.168.1.1
Last usableThe highest address you can give to a device192.168.1.254
Total addressesEvery address in the range, including the network and broadcast addresses256
Usable addressesThe total minus those two254
BinaryThe address you entered, written in binary11000000.10101000.00000001.00000000

The Binary row shows the address you typed, not the network address. Enter 192.168.1.57/24 and it shows the bits of 192.168.1.57.

For the two smallest networks the usable count equals the total. A /31 has two addresses and both are counted as usable. A /32 is a single address.

An IPv4 address is a 32-bit number

A computer stores an IPv4 address as 32 bits, each of them a 0 or a 1. People write it as four decimal numbers separated by dots because 32 digits in a row are hard to read. Each of the four numbers stands for 8 bits, which is why it is called an octet and why it can only run from 0 to 255.

Inside an octet, each bit has a fixed value. From left to right the values are 128, 64, 32, 16, 8, 4, 2 and 1. To convert an octet to binary, work from the left and write a 1 for every value that still fits into what is left of the number.

OctetSum of bit valuesBinary
192128 + 6411000000
168128 + 32 + 810101000
1100000001
7764 + 8 + 4 + 101001101
255All eight values11111111

Put the four octets side by side and you have the whole address. 192.168.1.0 is 11000000 10101000 00000001 00000000. The same 32 bits can also be read as one whole number, which is what IPv4 to Decimal shows.

What the prefix length and the mask mean

Every address has two parts. The bits on the left identify the network, and the bits on the right identify one device (a host) inside it. The prefix length says where the split is. In 192.168.1.0/24 the first 24 bits are the network part and the remaining 8 bits are the host part.

The subnet mask says the same thing in another form. It is a 32-bit number with a 1 for every network bit and a 0 for every host bit. A /24 mask is 24 ones followed by 8 zeros, which reads as 255.255.255.0 in dotted form. Many settings screens ask for the mask, while documentation and routing tables usually give the prefix.

The ones in a mask always sit on the left with no gaps, so an octet of a mask can take only nine values.

Network bits in the octetBinaryMask octet
0000000000
110000000128
211000000192
311100000224
411110000240
511111000248
611111100252
711111110254
811111111255

To turn a mask into a prefix length, add up the network bits of its four octets. 255.255.240.0 is 8 + 8 + 4 + 0, so it is a /20.

A worked example in binary

Take 203.0.113.77/26. The 26-bit prefix covers the first three octets completely, so only the last octet needs any work. Its first 2 bits belong to the network and its last 6 bits belong to the host.

ValueLast octet in binaryDecimal
Address0100110177
Subnet mask11000000192
Network (address AND mask)0100000064
Wildcard mask (mask flipped)0011111163
Broadcast (host bits set to 1)01111111127

The network address keeps the network bits of the address and sets every host bit to 0. In practice you compare the address and the mask bit by bit and write a 1 only where both have a 1. That operation is called AND. Here it leaves 01000000, so the network is 203.0.113.64/26.

The broadcast address keeps the same network bits and sets every host bit to 1, which gives 01111111, or 203.0.113.127. The usable addresses are everything in between: 203.0.113.65 to 203.0.113.126. Six host bits make 64 addresses, and 62 are left once the network and broadcast addresses are taken out.

When the split falls in another octet, the same steps apply there. In 10.20.30.40/20 it falls inside the third octet. The number 30 is 00011110, the mask octet is 11110000 (240), and the AND of the two is 00010000, which is 16. The network is 10.20.16.0/20 and the broadcast address is 10.20.31.255, with 4,096 addresses in total.

Wildcard masks and where they are used

A wildcard mask is the subnet mask turned inside out: every 1 becomes a 0 and every 0 becomes a 1. You can get it without binary by subtracting each octet of the mask from 255. For 255.255.255.192 that gives 0.0.0.63.

A subnet mask marks the bits that must match, and a wildcard mask marks the bits that may vary. Some router and firewall software expects this second form, most often in access control lists (rules that permit or block traffic by address) and in the configuration of the OSPF routing protocol. A rule written as 203.0.113.64 0.0.0.63 covers the same 64 addresses as 203.0.113.64/26.

Entering a subnet mask where a wildcard mask is expected is a common mistake, and the rule then matches the wrong addresses. The Wildcard mask row gives the value to copy.

The private address ranges

Three blocks of IPv4 addresses are set aside for private networks. Anyone may use them inside a home or company network, and routers on the public internet do not carry traffic to them. A router translates between the private addresses inside and a public address outside, a technique called NAT (network address translation).

BlockRangeAddresses
10.0.0.0/810.0.0.0 to 10.255.255.25516,777,216
172.16.0.0/12172.16.0.0 to 172.31.255.2551,048,576
192.168.0.0/16192.168.0.0 to 192.168.255.25565,536

The middle block is the one most often misread. Its /12 prefix ends inside the second octet, so it covers 172.16 through 172.31 and nothing else. An address such as 172.32.0.1 is a public address.

Networks are usually cut out of these blocks in smaller pieces. A home router that hands out 192.168.1.x addresses is using one /24 out of the 256 that fit in 192.168.0.0/16.

Questions this calculation settles

  • Two devices on the same cable or Wi-Fi cannot reach each other. Enter each address with its prefix. If the Network rows differ, the devices are in different networks and need a router, or a corrected mask, to talk.
  • You were given a mask and need the prefix, or the other way round. Enter any address with the prefix you think is right and compare the Subnet mask row.
  • You need the range that a firewall rule or an allow list covers. The Network row is the block to enter, and the Network and Broadcast rows show where it starts and ends.
  • An address ending in .0 or .255 looks wrong. In a network larger than a /24 it can be an ordinary host address. 10.20.17.0 sits in the middle of 10.20.16.0/20 and can be assigned to a device.

What the calculator does not do

It works on the numbers only. It does not know which addresses are in use on your network, whether a block is routed on the internet, or who an address belongs to. For the organization behind a public address, use IP Lookup.

One network is calculated at a time. The tool does not list the subnets inside a larger block and does not check two blocks for overlap, although you can compare two results yourself.

Only IPv4 is handled. IP Tracker does not keep a history of what you enter.

Frequently asked questions

What does the /24 after an IP address mean?

It is the prefix length: the number of bits, counted from the left, that identify the network. A /24 means the first 24 of the 32 bits are the network part, so the first three octets are fixed and the last one varies.

The notation is called CIDR, short for Classless Inter-Domain Routing. 192.168.1.0/24 and "192.168.1.0 with mask 255.255.255.0" describe the same network.

How do I convert a subnet mask to a prefix length?

Count the 1 bits in the mask. An octet of 255 has 8 of them, 0 has none, and the table of mask octets above gives the values in between. 255.255.255.224 is 8 + 8 + 8 + 3, so it is a /27.

What is the difference between a subnet mask and a wildcard mask?

They are opposites. A subnet mask has 1 bits for the network part, and a wildcard mask has 1 bits for the host part. 255.255.255.0 and 0.0.0.255 describe the same /24.

Operating systems and device settings use the subnet mask. Wildcard masks appear mainly in access control lists and OSPF configuration on some routers.

Why can the network address and the broadcast address not be given to a device?

Both have a reserved meaning. The address with every host bit set to 0 names the network itself. The address with every host bit set to 1 is the broadcast address, which every device in the network listens to.

That is why Usable addresses is two less than Total addresses for every prefix up to /30.

How many addresses does a prefix contain?

Subtract the prefix length from 32 to get the number of host bits, then raise 2 to that power. A /26 has 6 host bits and 64 addresses. A /16 has 16 host bits and 65,536 addresses.

Can I enter a private address such as 192.168.1.0/24?

Yes. The calculation is done in your browser and nothing is sent to the address, so private and public addresses are handled in the same way.

Does the calculator work with IPv6?

No. It accepts IPv4 addresses only. IPv6 addresses are 128 bits long and are written differently. To change how an IPv6 address is written, use IPv6 Compressor or IPv6 Expander.