本地网络的 CIDR 范围是什么意思,我们如何检查它?

What does it mean by CIDR range for the local network and how could we check it?

我尝试在我的裸机服务器上安装 Google Anthos。但我一直在寻找设置 yaml 配置所需的 ip 地址。我发现一篇文章 https://cloud.google.com/blog/topics/developers-practitioners/hands-anthos-bare-metal 陈述了一个声明

The CIDR range for my local network is 192.168.86.0/24. Furthermore, I have my Intel NUCs all on the same switch, so they are all on the same L2 network. 

作者所说的这个 CIDR 范围是什么?我们如何在终端中检查本地网络的 CIDR 范围? (我用的是LinuxUbuntu18机

将此答案作为社区 Wiki 发布,因为@John Hanley 在评论中解决了这个问题。

随意edit/expand吧。

The CIDR range is determined by your network. If you look at another machine on the same network running Windows, Linux or macOS, it is fairly easy to determine. Run a network utility such as ipconfig, ifconfig, ip, etc. Look for netmask or Subnet Mask. Common values are 255.255.255.0 which is CIDR /24 or 255.255.0.0 which is CIDR /16.

There are tools on the Internet to translate from netmasks to CIDRs. In simple terms a CIDR is the number of most significant consecutive ones in a netmask. If you convert 255 to binary, that is 8 ones. Repeat. 255.255.255.0 has 24 consecutive ones.

Note that a lot of networks are not setup correctly for client machines. It is generally best to speak to someone who controls your network. The router or network switch will have the correct netmask value. Use that value if available. It is also important to know if IP addresses are static or allocated by a DHCP server and the DNS servers.

示例:

  • ip a (10.211.55.4/24)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
      <-- OMITTED --> 
2: enp0s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:1c:42:1a:1e:57 brd ff:ff:ff:ff:ff:ff
    inet --> 10.211.55.4/24 <-- brd 10.211.55.255 scope global dynamic enp0s5
      <-- OMITTED --> 

A side note explanation:

By that example of network configuration the CIDR will be 10.211.55.0/24.

Jodies.de: Ipcalc


除此之外,还有关于 Anthos 的大量文档:

问题相关的网络部分可以在这里找到:


其他资源: