Home › Developer Tools › IP Range to CIDR

IP Range to CIDR

Firewalls, cloud security groups and allow lists usually want CIDR notation, not ranges. Type the first and last IP address and get the shortest list of CIDR blocks that covers exactly those addresses, nothing more.

Last updated:

IPv4 or IPv6. You can also paste "start - end" here

Enter your values to see the result.
Advertisement
Advertisement

How to use the IP Range to CIDR

  1. Enter the start IP, for example 192.168.1.10 or 2001:db8::1.
  2. Enter the end IP of the same version. You can also paste start - end into the first box.
  3. Press Convert to CIDR. The result shows how many blocks are needed and lists each one.
  4. Copy or download the CIDR list for your firewall, ACL or cloud rule.

How the CIDR list is built

A CIDR block a.b.c.d/n contains 232−n addresses and must begin on an address that is a multiple of that size. To cover an arbitrary range exactly, the converter repeatedly takes the largest aligned block that still fits:

  1. Convert the start and end IP to integers.
  2. Find the biggest power of two 2k that divides the start and where start + 2k − 1 ≤ end.
  3. Output start/(32 − k) (or 128 − k for IPv6) and set start = start + 2k.
  4. Repeat until start passes the end.

Example: 10.0.0.6 to 10.0.0.17. 10.0.0.6 is only divisible by 2, giving 10.0.0.6/31. Then 10.0.0.8 is divisible by 8, and 8 to 15 fits, so 10.0.0.8/29. Then 10.0.0.16 to 10.0.0.17 is 10.0.0.16/31. Three blocks, 12 addresses.

Ranges that map to a single block

Start IPEnd IPCIDRAddresses
10.0.0.010.255.255.25510.0.0.0/816,777,216
172.16.0.0172.31.255.255172.16.0.0/121,048,576
192.168.0.0192.168.255.255192.168.0.0/1665,536
192.168.4.0192.168.7.255192.168.4.0/221,024
192.168.1.0192.168.1.255192.168.1.0/24256
192.168.1.64192.168.1.127192.168.1.64/2664
2001:db8::2001:db8:0:ffff:ffff:ffff:ffff:ffff2001:db8::/48280

Tips

  • Most firewalls and cloud rules accept a list of CIDRs; some have a limit on entries, so check the block count before pasting.
  • If a rule limit is tight, the "smallest single covering block" is an option, but it allows addresses outside your range.
  • Ranges from geolocation or abuse databases are often published as start and end IPs: convert them before importing.

Frequently asked questions

How do you convert an IP range to CIDR?

Start at the first address and take the largest block of size 2^k that starts on a multiple of 2^k and does not pass the end address. Write it as start/(32 − k) for IPv4, move the start past it and repeat until the end is reached. This greedy method always gives the minimal list.

Why do I get several CIDR blocks instead of one?

A single CIDR block must start on a boundary that is a multiple of its size and contain a power-of-two number of addresses. A range like 192.168.1.10 to 192.168.1.100 is neither, so it has to be split into 7 blocks: /31, /30, /28, /27, /27, /30 and /32.

Can I cover the range with just one block?

Only if you accept extra addresses. The tool shows the smallest single block that contains the whole range, for example 192.168.1.0/25 for .10 to .100, and how many addresses outside your range it would include.

What is the maximum number of blocks a range can need?

For IPv4 at most 62 blocks (two per bit level, minus the ends); for IPv6 at most 254. In practice most ranges need far fewer.

Does it work with IPv6?

Yes. IPv6 addresses can be typed in compressed (2001:db8::1) or full form, and the calculations use exact 128-bit integers, so even enormous ranges are converted correctly.

What is the opposite conversion?

To turn a CIDR block such as 10.0.0.0/22 into its first and last IP, use a CIDR to IP range converter. Both directions describe the same set of addresses.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CIDR to IP RangeConvert IPv4 or IPv6 CIDR blocks to first/last IP, mask and host count, and export IP lists.Subnet CalculatorCalculate IPv4 network, broadcast, host range, masks and host count, and split subnets.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.IPv6 Subnet CalculatorIPv6 prefix to network, range, address count and /64s, and split it into child subnets.Email ValidatorCheck email lists and spot disposable addresses.Website Down CheckerCheck if a website is down for everyone.Deep Link GeneratorCreate links that open directly in apps.URL ParserBreak a URL into its parts and edit query string parameters with a live rebuild.User Agent ParserSee your user agent and parse any UA string into browser, OS, engine and device.HTTP Status CodesSearch every HTTP status code with plain-English meanings, causes, fixes and RFC references.Bulk URL OpenerOpen a list of URLs in new tabs at once or in batches, with cleanup, dedupe and delay.DNS LookupLook up A, AAAA, MX, TXT, NS, CNAME, SOA and CAA records with TTLs over secure DNS.API Request TesterSend GET, POST, PUT and DELETE requests with headers and a body, then inspect the response.WebSocket TesterConnect to a ws:// or wss:// server, send messages and watch a timestamped live log.WHOIS LookupLook up who registered a domain or IP: registrar, creation and expiry dates, name servers, status.Mailto Link GeneratorBuild encoded mailto: links with cc, bcc, subject and body, plus HTML code and a QR code.WhatsApp Link GeneratorCreate wa.me click-to-chat links with a pre-filled message, button HTML and a QR code.Basic Auth Header GeneratorCreate an Authorization: Basic header from a username and password, or decode one.Common Ports ListSearchable TCP/UDP port number list with service, protocol and description, filterable by range.DMARC CheckerLook up a domain's DMARC record, explain every tag, grade the policy and get fix suggestions.DMARC Record GeneratorCreate a DMARC TXT record with policy, reporting and alignment options, every tag explained.Email Header AnalyzerPaste raw email headers to trace every server hop, see delays and check SPF, DKIM and DMARC.IP Geolocation LookupFind the country, city, ISP, ASN and time zone of any IP address or domain, with a map.Reverse DNS LookupFind the PTR hostname of any IPv4 or IPv6 address, one at a time or hundreds in bulk.SPF Record CheckerLook up a domain's SPF record, count nested DNS lookups, find errors and test a sender IP.SPF Record GeneratorBuild a valid SPF TXT record from mail providers, IPs and includes, with a lookup-count check.DNS Propagation CheckerCompare DNS answers and TTLs from Cloudflare, Google, Quad9, AdGuard and NextDNS side by side.Domain Availability CheckerCheck if domain names are available across .com, .io, .ai and more, with registrar and expiry.MAC Address LookupFind the vendor of a MAC address or OUI, check multicast and random bits, look up many at once.MX LookupFind a domain's mail servers: MX priority, host, IP addresses and the email provider.Uptime SLA CalculatorTurn 99.9% uptime into allowed downtime per day, month and year, or downtime into uptime %.Website Speed TestTest page speed with Lighthouse: performance score, Core Web Vitals and fixes, mobile or desktop.ASN LookupLook up an AS number or IP: network owner, country, registry, abuse contact and announced prefixes.Bandwidth CalculatorEstimate monthly website bandwidth (GB) and the Mbps you need from page views and page size.CNAME LookupFollow a hostname's full CNAME chain to its final IP addresses, with TTLs and CDN detection.CORS TesterSend GET, POST or OPTIONS from your browser to any API and see whether CORS allows it and why not.DKIM Record CheckerLook up a domain's DKIM key by selector (or auto-detect), check key type, bit length and tags.DKIM Record GeneratorCreate a DKIM RSA key pair in your browser with the TXT record, selector host and private key PEM.HTTP Header ParserPaste raw HTTP headers to get a table explaining each one plus a security headers grade.IP Blacklist CheckerCheck an IPv4 address against 21 public spam blocklists (DNSBLs) and see listed or clean.Link in Bio Page GeneratorCreate a link-in-bio page with avatar, bio, links and theme, then download it as one HTML file.NS LookupFind a domain's authoritative nameservers with their IPs, SOA record and DNS hosting provider.Social Share Link GeneratorMake share links and buttons for Facebook, X, LinkedIn, Reddit, Pinterest, WhatsApp and email.Subnet Mask Cheat SheetInteractive /0 to /32 table of subnet masks, wildcards and host counts with details per prefix.TXT Record LookupLook up a domain’s DNS TXT records and see which are SPF, DMARC, DKIM or verification tokens.VLSM CalculatorSplit a network into variable-length subnets sized to the hosts each one needs.YouTube Timestamp Link GeneratorMake YouTube links that start at a set time, embed start/end codes and lists of timestamps.DMARC Report AnalyzerRead DMARC aggregate XML reports (.xml, .gz, .zip): sources, SPF/DKIM alignment and pass rates.Domain Age CheckerSee how old a domain is, when it was registered and when it expires. Bulk check up to 50.Email Deliverability CheckerGrade a domain's MX, SPF, DMARC, DKIM, BIMI and MTA-STS records in one report with fixes.Email ObfuscatorHide an email address from spam bots with HTML entities, a JavaScript mailto link or reversed CSS text.Email PermutatorGenerate every common business email format from a first name, last name and company domain.
See all 52 Network, DNS & Email Tools →