Results
IP Properties
02 / HISTORY

Your recent calculations.

03 / SUPERNET

Aggregate multiple subnets into one.

04 / OVERLAP CHECK

Detect conflicting CIDRs before they bite.

05 / WILDCARD MASK

Convert masks any direction.

Cisco ACL example
access-list 10 permit 192.168.1.0 0.0.0.255
06 / REVERSE SUBNETTING

How many hosts do you need?

CODE EXAMPLES

Compute subnet info from CIDR — in code

The same subnet math the calculator runs in your browser is just a few lines in any language. The example below prints the network address, broadcast, mask, wildcard, and host count for 192.168.1.0/24 in six languages. Every snippet is self-contained, prints identical output, and can be pasted straight into a script.

import ipaddress

net = ipaddress.IPv4Network("192.168.1.0/24", strict=False)
mask = net.netmask
wild = ipaddress.IPv4Address(int(mask) ^ 0xFFFFFFFF)
total = net.num_addresses
usable = max(0, total - 2)

print(f"IP:        {net.network_address}/{net.prefixlen}")
print(f"Mask:      {mask}")
print(f"Wildcard:  {wild}")
print(f"Network:   {net.network_address}")
print(f"Broadcast: {net.broadcast_address}")
print(f"Total:     {total}")
print(f"Usable:    {usable}")
package main

import (
	"fmt"
	"net"
)

func main() {
	ip, ipnet, _ := net.ParseCIDR("192.168.1.0/24")
	prefixLen, _ := ipnet.Mask.Size()

	mask := ipnet.Mask
	wild := net.IPv4(^mask[0], ^mask[1], ^mask[2], ^mask[3]).To4()

	broadcast := make(net.IP, 4)
	for i := 0; i < 4; i++ {
		broadcast[i] = ipnet.IP[i] | ^mask[i]
	}

	total := 1 << (32 - prefixLen)
	usable := total - 2
	if usable < 0 {
		usable = 0
	}

	maskIP := net.IPv4(mask[0], mask[1], mask[2], mask[3])

	fmt.Printf("IP:        %s/%d\n", ip, prefixLen)
	fmt.Printf("Mask:      %s\n", maskIP.To4())
	fmt.Printf("Wildcard:  %s\n", wild)
	fmt.Printf("Network:   %s\n", ipnet.IP)
	fmt.Printf("Broadcast: %s\n", broadcast)
	fmt.Printf("Total:     %d\n", total)
	fmt.Printf("Usable:    %d\n", usable)
}
function ip2int(s) {
  return s.split('.').reduce((a, o) => (a << 8) + +o, 0) >>> 0;
}
function int2ip(n) {
  return [24, 16, 8, 0].map(s => (n >>> s) & 0xff).join('.');
}

const [ipStr, prefixStr] = "192.168.1.0/24".split('/');
const prefix = +prefixStr;
const mask   = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;
const wild   = (~mask) >>> 0;
const net    = (ip2int(ipStr) & mask) >>> 0;
const bcast  = (net | wild) >>> 0;
const total  = 2 ** (32 - prefix);
const usable = Math.max(0, total - 2);

console.log(`IP:        ${ipStr}/${prefix}`);
console.log(`Mask:      ${int2ip(mask)}`);
console.log(`Wildcard:  ${int2ip(wild)}`);
console.log(`Network:   ${int2ip(net)}`);
console.log(`Broadcast: ${int2ip(bcast)}`);
console.log(`Total:     ${total}`);
console.log(`Usable:    ${usable}`);
#!/usr/bin/env bash
# Compute subnet info for a given CIDR.

CIDR="192.168.1.0/24"
IP="${CIDR%/*}"
PREFIX="${CIDR#*/}"

ip2int() {
  local IFS=.
  local -a o=($1)
  echo $(( (o[0]<<24) | (o[1]<<16) | (o[2]<<8) | o[3] ))
}
int2ip() {
  printf "%d.%d.%d.%d" \
    $(( ($1 >> 24) & 0xff )) \
    $(( ($1 >> 16) & 0xff )) \
    $(( ($1 >> 8)  & 0xff )) \
    $(( $1 & 0xff ))
}

MASK=$(( (0xFFFFFFFF << (32 - PREFIX)) & 0xFFFFFFFF ))
WILD=$(( (~MASK) & 0xFFFFFFFF ))
NET=$(( $(ip2int "$IP") & MASK ))
BCAST=$(( NET | WILD ))
TOTAL=$(( 1 << (32 - PREFIX) ))
USABLE=$(( TOTAL - 2 ))

printf "IP:        %s/%s\n" "$IP" "$PREFIX"
printf "Mask:      %s\n" "$(int2ip $MASK)"
printf "Wildcard:  %s\n" "$(int2ip $WILD)"
printf "Network:   %s\n" "$(int2ip $NET)"
printf "Broadcast: %s\n" "$(int2ip $BCAST)"
printf "Total:     %d\n" "$TOTAL"
printf "Usable:    %d\n" "$USABLE"
public class SubnetInfo {
    static String int2ip(long n) {
        return String.format("%d.%d.%d.%d",
            (n >> 24) & 0xff, (n >> 16) & 0xff,
            (n >> 8)  & 0xff, n & 0xff);
    }
    static long ip2int(String s) {
        String[] p = s.split("\\.");
        return ((Long.parseLong(p[0]) << 24)
              | (Long.parseLong(p[1]) << 16)
              | (Long.parseLong(p[2]) <<  8)
              |  Long.parseLong(p[3])) & 0xFFFFFFFFL;
    }
    public static void main(String[] args) {
        String cidr = "192.168.1.0/24";
        String ip   = cidr.split("/")[0];
        int prefix  = Integer.parseInt(cidr.split("/")[1]);

        long mask  = (prefix == 0) ? 0L
                   : (0xFFFFFFFFL << (32 - prefix)) & 0xFFFFFFFFL;
        long wild  = (~mask) & 0xFFFFFFFFL;
        long net   = ip2int(ip) & mask;
        long bcast = net | wild;
        long total = 1L << (32 - prefix);
        long usable = Math.max(0, total - 2);

        System.out.printf("IP:        %s/%d%n", ip, prefix);
        System.out.printf("Mask:      %s%n", int2ip(mask));
        System.out.printf("Wildcard:  %s%n", int2ip(wild));
        System.out.printf("Network:   %s%n", int2ip(net));
        System.out.printf("Broadcast: %s%n", int2ip(bcast));
        System.out.printf("Total:     %d%n", total);
        System.out.printf("Usable:    %d%n", usable);
    }
}
#include <stdio.h>
#include <stdint.h>
#include <string.h>

static void int2ip(uint32_t n, char *out) {
    sprintf(out, "%u.%u.%u.%u",
        (n >> 24) & 0xff, (n >> 16) & 0xff,
        (n >> 8)  & 0xff,  n        & 0xff);
}
static uint32_t ip2int(const char *s) {
    unsigned a, b, c, d;
    sscanf(s, "%u.%u.%u.%u", &a, &b, &c, &d);
    return (a << 24) | (b << 16) | (c << 8) | d;
}

int main(void) {
    const char *ip = "192.168.1.0";
    int prefix = 24;

    uint32_t mask  = (prefix == 0) ? 0u : (uint32_t)(0xFFFFFFFFu << (32 - prefix));
    uint32_t wild  = ~mask;
    uint32_t net   = ip2int(ip) & mask;
    uint32_t bcast = net | wild;
    uint64_t total = 1ULL << (32 - prefix);
    uint64_t usable = (total > 2) ? total - 2 : 0;

    char buf[20];
    printf("IP:        %s/%d\n", ip, prefix);
    int2ip(mask, buf);  printf("Mask:      %s\n", buf);
    int2ip(wild, buf);  printf("Wildcard:  %s\n", buf);
    int2ip(net,  buf);  printf("Network:   %s\n", buf);
    int2ip(bcast,buf);  printf("Broadcast: %s\n", buf);
    printf("Total:     %llu\n", (unsigned long long)total);
    printf("Usable:    %llu\n", (unsigned long long)usable);
    return 0;
}
IP:        192.168.1.0/24
Mask:      255.255.255.0
Wildcard:  0.0.0.255
Network:   192.168.1.0
Broadcast: 192.168.1.255
Total:     256
Usable:    254
FAQ

Frequently asked questions

How does the IPv4 subnet calculator work?

Enter an IP address and CIDR prefix (or click a /N preset). The calculator computes the network and broadcast addresses, first and last usable host, subnet mask, wildcard mask, host count, hex form, IP class, and address type (private/public). All math runs in your browser.

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

A subnet mask marks the network bits with 1s (e.g. 255.255.255.0 = /24). A wildcard mask is its bitwise inverse (0.0.0.255 for /24), where 1s mark "don't care" host bits. Cisco access lists and OSPF area definitions use wildcards; routing and addressing use subnet masks.

How do I check if two CIDRs overlap?

Use the overlap detector in the calculator: paste two CIDR ranges and it returns whether they overlap, where they overlap, and the affected address range. Two networks A and B overlap when A.start ≤ B.end AND B.start ≤ A.end.

Can I supernet (aggregate) multiple CIDRs?

Yes. Paste a list of contiguous adjacent CIDRs and the supernet calculator returns the smallest containing prefix. For example, 10.0.0.0/24 and 10.0.1.0/24 aggregate to 10.0.0.0/23.

REFERENCES

Common prefix references