IP Subnet Calculator

Calculate IPv4 network address, broadcast address, CIDR notation, wildcard mask and usable host range.

Back to all tools on ToolForge

More in Web & Network


Result

Enter IP and subnet mask, then click Calculate.

About IP Subnet Calculator

This IPv4 subnet calculator computes network address, broadcast address, CIDR notation, wildcard mask, and usable host range from an IP address and subnet mask (or CIDR prefix).

It is useful for network planning, subnet design, firewall rule configuration, VLAN setup, and understanding IP addressing for both IPv4 networks.

Subnet Calculation Formulas

IP to 32-bit number:
  n = (octet1 << 24) + (octet2 << 16) + (octet3 << 8) + octet4
  Example: 192.168.1.100 → 3232235876

CIDR to subnet mask:
  mask = (0xFFFFFFFF << (32 - cidr)) & 0xFFFFFFFF
  /24: 11111111.11111111.11111111.00000000 = 255.255.255.0

Network address (bitwise AND):
  network = ip & mask
  192.168.1.100 & 255.255.255.0 = 192.168.1.0

Broadcast address:
  wildcard = ~mask (bitwise NOT)
  broadcast = network | wildcard
  192.168.1.0 | 0.0.0.255 = 192.168.1.255

Usable hosts:
  hosts = 2^(32 - cidr) - 2
  /24: 2^8 - 2 = 254 hosts
  First host: network + 1
  Last host: broadcast - 1

Common Subnet Masks Reference

CIDRSubnet MaskWildcardTotal IPsUsable Hosts
/32255.255.255.2550.0.0.011 (single host)
/30255.255.255.2520.0.0.342 (point-to-point)
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.2551,0241,022
/21255.255.248.00.0.7.2552,0482,046
/20255.255.240.00.0.15.2554,0964,094
/19255.255.224.00.0.31.2558,1928,190
/18255.255.192.00.0.63.25516,38416,382
/17255.255.128.00.0.127.25532,76832,766
/16255.255.0.00.0.255.25565,53665,534
/12255.240.0.00.15.255.2551,048,5761,048,574
/8255.0.0.00.255.255.25516,777,21616,777,214

Private IP Address Ranges

ClassRangeCIDRUse Case
Class A10.0.0.0 – 10.255.255.25510.0.0.0/8Large networks
Class B172.16.0.0 – 172.31.255.255172.16.0.0/12Medium networks
Class C192.168.0.0 – 192.168.255.255192.168.0.0/16Small/home networks
Loopback127.0.0.0 – 127.255.255.255127.0.0.0/8Localhost testing

Calculation Example

Input:
  IP: 192.168.1.100
  Mask: 255.255.255.0 (or /24)

Step 1: Convert to binary
  IP:       11000000.10101000.00000001.01100100
  Mask:     11111111.11111111.11111111.00000000

Step 2: AND for network
  Network:  11000000.10101000.00000001.00000000
            = 192.168.1.0

Step 3: Invert mask for wildcard
  Wildcard: 00000000.00000000.00000000.11111111
            = 0.0.0.255

Step 4: OR for broadcast
  Broadcast: 11000000.10101000.00000001.11111111
             = 192.168.1.255

Results:
  Network:     192.168.1.0/24
  Broadcast:   192.168.1.255
  First Host:  192.168.1.1
  Last Host:   192.168.1.254
  Usable:      254 hosts

Frequently Asked Questions

What is a subnet mask?
A subnet mask divides an IP address into network and host portions. Written as 255.255.255.0 or /24 (CIDR). The 1 bits represent the network, 0 bits represent hosts. Common masks: /24 (255.255.255.0) = 254 hosts, /16 (255.255.0.0) = 65,534 hosts, /32 = single host.
What is CIDR notation?
CIDR (Classless Inter-Domain Routing) notation uses a slash followed by the number of network bits: /24 means 24 bits for network, 8 for hosts. Replaced classful addressing (Class A/B/C). Example: 192.168.1.0/24 = network 192.168.1.0 with mask 255.255.255.0.
What is the network address?
The network address is the first address in a subnet (all host bits = 0). It identifies the subnet itself and cannot be assigned to hosts. Calculated by ANDing the IP address with the subnet mask. Example: 192.168.1.100/24 → network 192.168.1.0.
What is the broadcast address?
The broadcast address is the last address in a subnet (all host bits = 1). Packets sent to this address reach all hosts in the subnet. Calculated by ORing the network address with the wildcard mask. Example: 192.168.1.0/24 → broadcast 192.168.1.255.
What is a wildcard mask?
A wildcard mask is the inverse of a subnet mask (bits flipped). Used in ACLs and routing. Example: subnet 255.255.255.0 → wildcard 0.0.0.255. Calculated by subtracting each octet from 255. Wildcard = ~subnet_mask (bitwise NOT).
How many usable hosts per subnet?
Formula: 2^(host_bits) - 2. Subtract 2 for network and broadcast addresses. /24 = 8 host bits = 254 hosts, /25 = 7 bits = 126 hosts, /26 = 6 bits = 62 hosts, /30 = 2 bits = 2 hosts (point-to-point links).