Subnet Mask Converter

Convert between subnet mask formats: decimal, CIDR, binary, and hexadecimal.

About This Tool

The Subnet Mask Converter translates subnet masks between different notations used in networking: CIDR (slash notation), decimal (dotted quad), hexadecimal, and binary. Understanding subnet masks is fundamental to IP networking, subnetting, and network design. This tool also calculates wildcard masks (used in Cisco ACLs), network/host bit counts, and usable IP addresses for a given subnet. Whether you're configuring routers, designing networks, studying for certifications (CCNA, Network+), or troubleshooting routing issues, this converter helps you work with subnet masks in any format.

How to Use

  1. Select the input format from the dropdown (CIDR, Decimal, Hex, Binary)
  2. Enter your subnet mask in the chosen format:
  3. - CIDR: /24 or 24
  4. - Decimal: 255.255.255.0
  5. - Hexadecimal: 0xFFFFFF00 or FFFFFF00
  6. - Binary: 11111111.11111111.11111111.00000000 (dotted or continuous)
  7. Click "Convert" to see all format representations
  8. View network information including usable addresses and wildcard mask
  9. Use results for router configuration, ACL setup, or network documentation

Features

  • Convert between CIDR, decimal, hexadecimal, and binary formats
  • Calculate wildcard masks for Cisco ACLs
  • Show network and host bit counts
  • Calculate total and usable IP addresses
  • Subnet class identification
  • Support for all prefix lengths (/0 to /32)
  • Handles supernets and point-to-point links (/31)
  • Input validation with error messages
  • Clear visual presentation of all formats
  • Instant conversion results

Common Use Cases

  • Network design and IP address planning (VLSM)
  • Router and firewall configuration
  • Cisco IOS ACL wildcard mask calculation
  • CCNA/CCNP/Network+ certification exam prep
  • Troubleshooting routing and subnetting issues
  • Converting between vendor-specific formats
  • Documentation and network diagrams
  • Calculating available host addresses
  • Understanding binary subnet masks
  • Teaching and learning IP subnetting

Technical Details

A subnet mask is a 32-bit number that divides an IP address into network and host portions. It uses contiguous 1s for the network portion and 0s for the host portion.

Subnet Mask Formats:

  • CIDR Notation (Classless Inter-Domain Routing):
    • Format: Slash followed by prefix length (e.g., /24)
    • Prefix length = number of network bits (0-32)
    • Most concise format, standard in modern networking
    • Example: 192.168.1.0/24 means first 24 bits are network
  • Decimal (Dotted Quad):
    • Format: Four decimal octets (e.g., 255.255.255.0)
    • Each octet is 0-255
    • Traditional format used in older configurations
    • Example: 255.255.255.0 = /24
  • Hexadecimal:
    • Format: 0x followed by 8 hex digits (e.g., 0xFFFFFF00)
    • Used in some programming contexts and packet captures
    • Compact representation of 32-bit value
    • Example: 0xFFFFFF00 = 255.255.255.0 = /24
  • Binary:
    • Format: 32 binary digits, often dotted by octet
    • Shows actual bit pattern
    • Useful for understanding subnetting calculations
    • Example: 11111111.11111111.11111111.00000000 = /24

Common Subnet Masks:

  • /8 (255.0.0.0): Class A, 16,777,214 usable hosts
    • Example: 10.0.0.0/8 (entire Class A private range)
  • /16 (255.255.0.0): Class B, 65,534 usable hosts
    • Example: 172.16.0.0/16
  • /24 (255.255.255.0): Class C, 254 usable hosts
    • Example: 192.168.1.0/24 (common home/office network)
    • Most common subnet size for small networks
  • /30 (255.255.255.252): Point-to-point links, 2 usable hosts
    • Used for router-to-router connections
    • Example: 10.0.0.0/30 (hosts: .1 and .2, network: .0, broadcast: .3)
  • /31 (255.255.255.254): RFC 3021 point-to-point, 2 usable hosts
    • No network or broadcast address (both IPs usable)
    • Used exclusively for point-to-point links
  • /32 (255.255.255.255): Single host, 1 address
    • Used for loopback interfaces and static routes
    • Example: 127.0.0.1/32 (localhost)

Wildcard Masks:

  • Definition: Inverse of subnet mask (1s and 0s flipped)
  • Used in: Cisco IOS access control lists (ACLs) and OSPF configuration
  • Calculation: 255.255.255.255 - subnet mask
  • Examples:
    • Subnet mask 255.255.255.0 (/24) = Wildcard 0.0.0.255
    • Subnet mask 255.255.255.252 (/30) = Wildcard 0.0.0.3
    • Subnet mask 255.255.0.0 (/16) = Wildcard 0.0.255.255
  • Interpretation: 0 = must match, 1 = ignore (any value)
    • 0.0.0.255 means match first 3 octets, ignore last octet
  • ACL Example:
    access-list 10 permit 192.168.1.0 0.0.0.255
    # Matches 192.168.1.0-192.168.1.255 (entire /24 subnet)

Calculating Usable Addresses:

  • Total addresses: 2^(host bits)
    • Example: /24 has 8 host bits, so 2^8 = 256 total addresses
  • Usable addresses: Total - 2 (network and broadcast)
    • Example: /24 = 256 - 2 = 254 usable
    • Network address: First address (all host bits 0)
    • Broadcast address: Last address (all host bits 1)
  • Exception /31: RFC 3021 allows both IPs as usable (no network/broadcast)
  • Exception /32: Single host mask, 1 usable address

Subnetting Example (VLSM):

Given network 192.168.1.0/24, create 4 subnets:

  1. Calculate new prefix: /24 + 2 bits = /26 (2^2 = 4 subnets)
  2. Each subnet has 2^6 = 64 addresses (62 usable)
  3. Subnets:
    • 192.168.1.0/26 (0-63, usable: 1-62)
    • 192.168.1.64/26 (64-127, usable: 65-126)
    • 192.168.1.128/26 (128-191, usable: 129-190)
    • 192.168.1.192/26 (192-255, usable: 193-254)

Subnet Mask Rules:

  • Contiguous 1s: Network bits must be contiguous (no gaps)
    • Valid: 11111111.11111111.11111111.00000000 (/24)
    • Invalid: 11111111.11110000.11111111.00000000 (gap in 1s)
  • Network bits first: All network bits come before host bits
  • Valid prefixes: /0 (0.0.0.0) to /32 (255.255.255.255)

Common Conversion Shortcuts:

  • /8 = 255.0.0.0 (Class A default)
  • /16 = 255.255.0.0 (Class B default)
  • /24 = 255.255.255.0 (Class C default)
  • /25 = 255.255.255.128 (128 = 2^7)
  • /26 = 255.255.255.192 (192 = 128 + 64)
  • /27 = 255.255.255.224 (224 = 128 + 64 + 32)
  • /28 = 255.255.255.240 (240 = 128 + 64 + 32 + 16)
  • /29 = 255.255.255.248 (248 = 128 + 64 + 32 + 16 + 8)
  • /30 = 255.255.255.252 (252 = 128 + 64 + 32 + 16 + 8 + 4)

Binary Conversion Method:

  1. Write /24 as 24 ones followed by 8 zeros: 11111111.11111111.11111111.00000000
  2. Convert each octet to decimal: 255.255.255.0
  3. Reverse process: Convert decimal to binary, count leading 1s

Use in Routing:

  • Route aggregation: Summarizing multiple subnets with shorter prefix
    • Example: 10.1.0.0/24, 10.1.1.0/24, 10.1.2.0/24, 10.1.3.0/24 to 10.1.0.0/22
  • Longest prefix match: Routers use most specific (longest) subnet mask

Best Practices:

  • Use CIDR notation (/24) for modern networks (cleaner, more standard)
  • Use wildcard masks for Cisco ACLs (required by IOS syntax)
  • Document subnet masks in network diagrams
  • Plan IP address space with VLSM (Variable Length Subnet Masking) for efficiency
  • Reserve room for growth when subnetting