You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于将两个特定IP地址合并为合适CIDR网段的技术咨询

如何将两个特定IP地址合并为合适的CIDR网段?

Hey there, let's break this down step by step so it makes sense.

First off, let's clear up that /2 idea right away: that's a terrible fit. A /2 CIDR covers the entire range from 128.0.0.0 to 191.255.255.255—way, way broader than even a /24, so it's absolutely not what you want.

Now, to find the smallest CIDR that includes both 172.22.254.67 and 172.22.254.68, we need to look at their binary structure:

  • The last byte of 172.22.254.67 is 01000011
  • The last byte of 172.22.254.68 is 01000100

The first three octets (172.22.254) are identical, so we only care about the common prefix in the last byte. Comparing those two binary strings, the first 5 bits are the same (01000), and they diverge after that. Adding those 5 bits to the 24 bits from the first three octets gives us a 29-bit common prefix.

The correct CIDR for this is 172.22.254.64/29. Let's break down what this means:

  • The subnet mask here is 255.255.255.248
  • It covers the IP range from 172.22.254.64 to 172.22.254.71 (8 total IPs)

This is the smallest possible CIDR that includes both your target IPs. Unfortunately, there's no CIDR that only covers exactly these two IPs—since they sit on the edge of two smaller /30 subnets (one covering 64-67, the other 68-71), we have to go up one size to /29 to include both.

This solves your character limit issue (you only need one string) while keeping the allowed IP range much tighter than a /24.

备注:内容来源于stack exchange,提问作者oldenuf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 11:08:10