Monitoring
Solutions
Resources
Free Tools
Pricing
Free Tools / IP addresses / IPv4 Netmask Converter

IPv4 Netmask Converter

Enter a subnet mask, a prefix length or a wildcard mask. Get the other two, the binary form and the number of hosts — and a complete netmask table to check against.

All IPv4 netmasks

Runs entirely in your browser — nothing you enter here is sent to a server.

What a netmask does

A netmask tells a device which part of an address names the network and which part names the host. Written in binary it is a run of ones followed by a run of zeros: the ones cover the network bits. 255.255.255.0 is 24 ones and 8 zeros, so the first three numbers of the address are the network and the last one is the host. The prefix length /24 says the same thing by simply counting the ones.

A device applies the mask to decide whether another address is on its own network — and can be reached directly — or has to be sent to the gateway. Two machines with the same address plan but different masks will disagree about that, which is a classic cause of "it can reach some hosts but not others".

Netmask

Ones mark the network part. Used on interfaces, in routing tables and DHCP.

Prefix length

The number of ones. The compact CIDR form: /24 instead of 255.255.255.0.

Wildcard mask

The netmask inverted. Used by Cisco access lists and OSPF: 0.0.0.255 for a /24.

Only 33 valid masks

Because the ones must be contiguous, there is exactly one mask per prefix from /0 to /32.

Masks you will meet most often

/24 (255.255.255.0) is the default for small LANs: 254 hosts. /16 (255.255.0.0) covers 65,534 and is what a 172.16–31 or 10.x site network often uses. /30 (255.255.255.252) has two usable addresses and joins two routers; /31 does the same without wasting two addresses. /32 (255.255.255.255) names a single host — typical for loopback interfaces and firewall rules. /0 is the default route: every address.

Frequently asked questions

What is the netmask for /24?

255.255.255.0. It leaves 8 bits for hosts: 256 addresses, 254 of them usable.

How do I convert a subnet mask to CIDR?

Count the one-bits. Each 255 is eight ones; then 254 = 7, 252 = 6, 248 = 5, 240 = 4, 224 = 3, 192 = 2, 128 = 1. So 255.255.240.0 is 8 + 8 + 4 = /20.

What is a wildcard mask?

The netmask with every bit flipped: subtract each number from 255. For 255.255.255.0 it is 0.0.0.255. Cisco ACLs and OSPF network statements use it — a zero bit means "must match".

Is 255.255.255.253 a valid netmask?

No. In binary it ends in 11111101 — a zero in the middle of the ones. Valid masks are an unbroken run of ones followed only by zeros.

Related free tools

The right mask on the wrong interface takes a server off the network.

Upzilla pings your hosts around the clock and alerts you when one becomes unreachable. 10 monitors free.

Start monitoring free →