IP address and subnet calculator

Enter an IP address and a prefix length (or subnet mask) to get the network address, broadcast address, usable host range and count, and wildcard mask at once. The address and mask are shown in binary with the network and host parts in different colors, so you can see how ANDing with the mask works. The tool also lists the subnets you get by dividing the network into longer prefixes, finds the smallest subnet for a required number of hosts and tells you whether the address is private or reserved for another use. It is a quick way to check subnetting exercises, such as those in IT certification exams, after working them by hand.

Inputs

Results

CIDR notation
–
Network address
–
Broadcast address
–
First host
–
Last host
–
Usable hosts
–
Total addresses
–
Subnet mask
–
Wildcard mask
–
Address type
–
Class (for reference)
–

In binary

Network part Host part

Splitting into subnets

Sizing from the hosts needed

–

Only IPv4 is supported, and the usable host count excludes the network and broadcast addresses, except for /31 and /32.

Finding the network and broadcast addresses

The 32 bits of an IPv4 address split into a network part, the first n bits set by the prefix length, and a host part made of the rest. The subnet mask has 1s in the network part and 0s in the host part, and a bitwise AND of the IP address with the mask clears the host part to give the network address. For the default 192.168.10.77/27, the fourth octet 77 (0100 1101) ANDed with 224 (1110 0000) is 64 (0100 0000), so the network address is 192.168.10.64. Setting all five host bits to 1 gives 64 + 31 = 95, so the broadcast address is 192.168.10.95. The 30 addresses between them, 192.168.10.65 to 192.168.10.94, are the ones you can assign to hosts, and the binary view colors the network and host parts so you can follow each step.

Usable hosts, /31 and /32

A subnet with prefix length n holds 2^(32 − n) addresses. The network address (host part all 0s) and the broadcast address (host part all 1s) cannot be assigned to devices, so 2^(32 − n) − 2 are usable: 2^5 − 2 = 30 for /27 and 2^8 − 2 = 254 for /24. A /31 has only two addresses, so this rule would leave none. RFC 3021 allows both addresses of a /31 to be used on point-to-point links, where one router faces exactly one other, and this tool counts 2 usable hosts for /31. A /32 stands for a single address and is used for a router's loopback interface or for a route to one specific host (a host route).

Splitting a network and sizing by host count

Making the prefix k bits longer divides a network into 2^k subnets, each with 1/2^k of the original addresses. Splitting 192.168.10.0/24 into /26 gives 2^2 = 4 subnets starting at .0, .64, .128 and .192, each holding 2^6 − 2 = 62 hosts. Enter 192.168.10.0 with prefix /24 and split into /26 to see the host range and broadcast address of all four. To size a subnet from the number of hosts needed, look for the longest prefix for which 2^(32 − n) − 2 is at least that number. For 500 hosts, /24 (254 hosts) is too small and /23 (2^9 − 2 = 510 hosts, mask 255.255.254.0) is the smallest that fits. A /23 starts at an even third octet; for example, 10.0.2.0/23 covers 10.0.2.0 to 10.0.3.255.

Private and special-purpose addresses

The RFC 1918 private ranges 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 can be used freely inside homes and organizations, and a router's NAT (NAPT) translates them to global addresses to reach the internet. 100.64.0.0/10 is the shared address space (RFC 6598) that carriers use inside carrier-grade NAT (CGN). Other ranges are set aside for loopback to the device itself (127.0.0.0/8), link-local addresses that some operating systems assign themselves when DHCP fails (169.254.0.0/16), multicast (224.0.0.0/4) and examples in documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24). The classes A to E shown by the tool come from the old classful scheme, in which the leading bits fixed the length of the network part; CIDR now lets the prefix length be chosen freely, so treat the class as background only. For example, 192.168.10.77 is class C, but here it is used as a /27 rather than a /24.

Wildcard masks

A wildcard mask is the subnet mask with its 0s and 1s swapped, which you get by subtracting each octet from 255. For the /27 mask 255.255.255.224, the wildcard mask is 0.0.0.31. Routers such as Cisco's use wildcard masks in ACLs (access control lists) and OSPF configuration, where a 1 bit means "don't care" and a 0 bit means "must match". For example, 192.168.10.64 0.0.0.31 matches the 32 addresses from 192.168.10.64 to 192.168.10.95. Unlike a subnet mask, an ACL wildcard mask does not need its 1 bits to be contiguous, so it can, for instance, match only even-numbered addresses.

Practice networking questions

In the network 192.168.5.0/26, how many IP addresses can be assigned to hosts (end devices or router interfaces)?

  1. A64
  2. B30
  3. C62
Show answer and explanation

Answer: C. 62

/26 means a 26-bit network part, so the host part is 32 − 26 = 6 bits and there are 2^6 = 64 addresses. Of these, the network address with the host part all 0s (192.168.5.0) and the broadcast address with it all 1s (192.168.5.63) cannot be assigned to hosts, leaving 64 − 2 = 62. In general, a prefix length of n gives 2^(32 − n) − 2 assignable addresses. The subnet mask for /26 is 255.255.255.192.

A host has IP address 192.168.10.77/27. What is the broadcast address of its subnet?

  1. A192.168.10.95
  2. B192.168.10.127
  3. C192.168.10.255
Show answer and explanation

Answer: A. 192.168.10.95

/27 leaves 32 − 27 = 5 host bits, so each subnet holds 2^5 = 32 addresses and the fourth octet starts at boundaries of 0, 32, 64, 96 and so on. 77 falls in the range 64–95, so the network address is 192.168.10.64 and the broadcast address, with the host part all 1s, is 64 + 32 − 1 = 95, giving 192.168.10.95. The assignable host addresses are the 30 addresses .65–.94. The subnet mask for /27 is 255.255.255.224.

You want to fit 500 hosts in one subnet. Of the subnets that can do this, which is the smallest (has the longest prefix)?

  1. A/24
  2. B/22
  3. C/23
Show answer and explanation

Answer: C. /23

A subnet with prefix length n can hold 2^(32 − n) − 2 hosts. /24 has 8 host bits, giving 2^8 − 2 = 254 hosts, which is not enough. /23 has 9 host bits, giving 2^9 − 2 = 510 hosts, enough for 500. /22 gives 2^10 − 2 = 1022 hosts, which also fits but uses about twice the addresses needed. The subnet mask for /23 is 255.255.254.0; for example, 10.0.2.0/23 covers 10.0.2.0 to 10.0.3.255.

FAQ

How do I find the network address by hand?

Octets where the mask is 255 stay as they are and octets where it is 0 become 0, so only the octet in between needs work. Its block size is 256 minus the mask value, and the network address is the largest multiple of the block size that does not exceed the address. For 192.168.10.77/27, the mask 224 gives a block of 32 and the largest multiple of 32 not above 77 is 64, so the network address is 192.168.10.64 and the broadcast address is 64 + 32 − 1 = 95, giving 192.168.10.95.

Why subtract 2 when counting hosts?

The address with the host part all 0s stands for the network itself, and the one with all 1s is the broadcast address that reaches every device in the subnet, so neither can be assigned to a device. A /24 therefore holds 256 − 2 = 254 hosts. The address of the router that serves as the default gateway is also one of these 254.

What is the difference between a subnet mask and CIDR notation?

Both give the length of the network part and carry the same information. A subnet mask writes all 32 bits as four decimal numbers, such as 255.255.255.224, while CIDR notation writes only the number of 1 bits, as in /27. Because the 1s in a mask are always contiguous from the left, each converts directly to the other, and this tool accepts either form.

What is a /31 used for?

It is used on point-to-point links that connect exactly two routers. With only one device at the other end, no broadcast address is needed, and RFC 3021 allows both addresses to be assigned to interfaces. Compared with a /30 (four addresses for two hosts), it uses half as many addresses.

Can it calculate IPv6 addresses?

No, this tool supports IPv4 only. IPv6 addresses are 128 bits long and are written with a prefix length, as in 2001:db8::/64, rather than a subnet mask. LAN subnets normally use /64, leaving the lower 64 bits for the interface ID, and stateless address autoconfiguration (SLAAC) relies on this /64. IPv6 also has no broadcast address; multicast takes over that role.

Related terms

Subnet mask CIDR NAT (Network Address Translation) Default gateway ARP DHCP VLAN OSI reference model

Related calculators

Semiconductor, Electronics and Computing Calculators →