在网络规划和管理过程中,IP地址是必须要考虑的一个重要因素。而对于复杂的网络环境,如何进行IP地址规划成了一件非常麻烦的事情。不过,在Linux系统中,有一款子网计算工具——Sipcalc,它可以简化我们进行IP地址规划的过程,让我们轻松应对各种IP地址相关的需求。
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地址规划工具,它可以在Linux系统中方便地进行使用。通过本文的介绍,我们可以学习到如何在Linux系统中使用Sipcalc计算工具来规划IP地址、子网、掩码等相关信息,并且可以学习到如何借助Sipcalc计算工具进行网络问题排除和定位。相信这些技巧将帮助你更加高效和准确地进行IP地址规划,为你的网络环境提供更加优秀的服务。
以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !