1

假设我们有一个地址为:172.31.219.33/27的路由器,我可以告诉你几件事:

  1. 子网掩码:255.255.255.224
  2. 广播地址(这里我不确定最后一位应该是 64 还是 65 - 见后文):172.31.219.64
  3. 最后主机地址(因为我们知道广播地址;也不确定最后一位应该是 63 还是 62):172.31.219.63

我们还可以告诉第一个主机地址(172.31.219.33)和网络地址(172.31.219.32)。

我不明白两件事:

  1. 为什么第一个主机地址是XXX33?就像路由器已经是主机一样?
  2. 为什么网络地址是XXX32?换句话说,为什么不是XXX33(来自路由器地址)?

编辑:还有谁能告诉我为什么它是 B 级地址而不是 C 级(因为 C 级的掩码是255.255.255.0 - 255.255.255.254)?

4

3 回答 3

1

32 - 27 = 5 所以屏蔽低 5 位以获得网络地址 32。广播通常设置所有子网位,因此将是 63。范围将为 32 - 63,但最低和最高保留,因此主机地址为 33 - 62。

B 类具有第一个八位字节 128 到 191。

于 2015-01-04T13:58:19.350 回答
1

对于您所做的问题前假设:

  1. 子网掩码为 255.255.255.224
  2. 广播地址不是 172.31.219.64 而是 172.31.219.63
  3. 最后主机地址不是 172.31.219.63 而是 172.31.219.62

现在你的问题:

  1. The first host address is 172.31.219.33 and yes, the router is a host. Router doesn't need to have the first IP address from the subnet and you can have multiple routers on the subnet, etc.
  2. Subnet address has nothing to do with the router's IP address, it's just a way of identifying the specific scope.
  3. It is not he C-class because you are not using classful but classless (CIDR) routing, so the mask is not an indicator of the class the address belongs to. You can see that I'm using the term subnet instead of network the whole time since 172.31.219.33/27 is the subnet of the 128.0.0.0/16 network - The class B network.

As stark explained in his comment all of the calculations are made by doing bitwise operations on the 32bit binary numbers that represent the IP and subnet mask, and if you really want to understand how all of this is calculated you should take a look at binary numbers not at the dot-decimal representations of them.

于 2015-01-04T16:13:03.220 回答
1

The network address is NOT the router's address. The router is using an IP address from one of the host addresses in the subnet. For example, if you have a subnet of eight IP addresses (0 - 7), 0 will be the network address and 7 will be the broadcast address. The router may use one of the IP addresses from in between these two [1 - 6]. As another example, look at the picture below. Each of the router's interfaces(underlined in red) is using an IP address from one of the host IP addresses in the respective subnet.

Interface addresses and subnets

Answering your second question, the address you provided is from the CIDR notation. CIDR stands for Classless Inter-Domain Routing. CIDR addresses do not have classes. They replace the previous classful IP addresses, which to my knowledge aren't used anymore.

于 2015-01-04T16:27:00.157 回答