导读 | Sipcalc 是一个行 ip 子网计算器,支持 IPv4 和 IPv6,它会显示你填写 DHCP 信息或设置静态 IP 地址所需的所有 IP 相关信息。Sipcalc 的开发始于 2001 年,它具有我们想要的 ip 计算器的大部分功能。 |
安装
在Centos8中安装sipcalc之前,需要先安装epel源。:
[root@localhost ~]# yum -y install epel-release [root@localhost ~]# yum -y install sipcalc
sipcalc 使用方式
下面使用 sipcalc 列出一个标准 24 位的 C 类网络示例:
[root@localhost ~]# sipcalc 192.168.10.0/24 -[ipv4 : 192.168.10.0/24] - 0 [CIDR] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network mask - 255.255.255.0 Network mask (bits) - 24 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.10.255 Cisco wildcard - 0.0.0.255 Addresses in network - 256 Network range - 192.168.10.0 - 192.168.10.255 Usable range - 192.168.10.1 - 192.168.10.254
可以看到列出了192.168.10.0/24网段中广播地址、反掩码、网络范围和可用的IP地址范围。
下面添加-a
查看一下:
[root@localhost ~]# sipcalc -a 192.168.10.0/24 -[ipv4 : 192.168.10.0/24] - 0 [Classful] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network class - C Network mask - 255.255.255.0 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.10.255 [CIDR] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network mask - 255.255.255.0 Network mask (bits) - 24 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.10.255 Cisco wildcard - 0.0.0.255 Addresses in network - 256 Network range - 192.168.10.0 - 192.168.10.255 Usable range - 192.168.10.1 - 192.168.10.254 [Classful bitmaps] Network address - 11000000.10101000.00001010.00000000 Network mask - 11111111.11111111.11111111.00000000 [CIDR bitmaps] Host address - 11000000.10101000.00001010.00000000 Network address - 11000000.10101000.00001010.00000000 Network mask - 11111111.11111111.11111111.00000000 Broadcast address - 11000000.10101000.00001010.11111111 Cisco wildcard - 00000000.00000000.00000000.11111111 Network range - 11000000.10101000.00001010.00000000 - 11000000.10101000.00001010.11111111 Usable range - 11000000.10101000.00001010.00000001 - 11000000.10101000.00001010.11111110 [Networks] Network - 192.168.10.0 - 192.168.10.255 (current)
可以看到可以看到192.168.10.0网段的有类路由和无类路由的二进制形式。
下面使用一个27为掩码的网段:
[root@localhost ~]# sipcalc 192.168.10.0/27 -[ipv4 : 192.168.10.0/27] - 0 [CIDR] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network mask - 255.255.255.224 Network mask (bits) - 27 Network mask (hex) - FFFFFFE0 Broadcast address - 192.168.10.31 Cisco wildcard - 0.0.0.31 Addresses in network - 32 Network range - 192.168.10.0 - 192.168.10.31 Usable range - 192.168.10.1 - 192.168.10.30
可以看到可用地址为192.168.10.1-192.168.10.30
添加-a
选项,可以看到可用的网段有哪些:
[root@localhost ~]# sipcalc 192.168.10.0/27 -a -[ipv4 : 192.168.10.0/27] - 0 [Classful] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network class - C Network mask - 255.255.255.0 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.10.255 [CIDR] Host address - 192.168.10.0 Host address (decimal) - 3232238080 Host address (hex) - C0A80A00 Network address - 192.168.10.0 Network mask - 255.255.255.224 Network mask (bits) - 27 Network mask (hex) - FFFFFFE0 Broadcast address - 192.168.10.31 Cisco wildcard - 0.0.0.31 Addresses in network - 32 Network range - 192.168.10.0 - 192.168.10.31 Usable range - 192.168.10.1 - 192.168.10.30 [Classful bitmaps] Network address - 11000000.10101000.00001010.00000000 Network mask - 11111111.11111111.11111111.00000000 [CIDR bitmaps] Host address - 11000000.10101000.00001010.00000000 Network address - 11000000.10101000.00001010.00000000 Network mask - 11111111.11111111.11111111.11100000 Broadcast address - 11000000.10101000.00001010.00011111 Cisco wildcard - 00000000.00000000.00000000.00011111 Network range - 11000000.10101000.00001010.00000000 - 11000000.10101000.00001010.00011111 Usable range - 11000000.10101000.00001010.00000001 - 11000000.10101000.00001010.00011110 [Networks] Network - 192.168.10.0 - 192.168.10.31 (current) Network - 192.168.10.32 - 192.168.10.63 Network - 192.168.10.64 - 192.168.10.95 Network - 192.168.10.96 - 192.168.10.127 Network - 192.168.10.128 - 192.168.10.159 Network - 192.168.10.160 - 192.168.10.191 Network - 192.168.10.192 - 192.168.10.223 Network - 192.168.10.224 - 192.168.10.255
总结
Sipcalc 是一个行 ip 子网计算器,支持 IPv4 和 IPv6,它会显示你填写 DHCP 信息或设置静态 IP 地址所需的所有 IP 相关信息。
本文原创地址://lrxjmw.cn/linux-sipcalc-subnet.html编辑:逄增宝,审核员:逄增宝