Description of the subnet mask and subnetting

I. Overview of the subnet mask and the role of

  1. A subnet mask is applied to a TCP / 32-bit binary value of the IP network, each section 8, to be used in conjunction with the corresponding IP address.

  2. 32 corresponds to the subnet mask to the IP address 32, if a network address, the subnet mask is 1, and 0 otherwise.

  3. Subnet mask by the IP address "and" computing, isolated host address and a network address in the IP address, for determining whether the IP address on the LAN or WAN.

  4. The subnet mask is typically used to be further divided into several sub-networks, and to avoid excessive congestion host IP or too little waste.

Second, why should use the subnet mask?

The subnet mask can be isolated from the network and host addresses in the IP address, so why separate it? Because the two computers to communicate, we must first determine whether in the same broadcast domain, that the network address is the same. If the network addresses are the same, indicating that the recipient on this network, data packets can be sent directly to the target host, otherwise you will need a gateway router forwards the packet to the destination.

Third, the subnet mask classification

1) Default Subnet Mask:

(Not subnetting)

32-bit IP address and subnet mask 32 corresponding to, if a network address, the subnet mask is 1, and 0 otherwise. Class A IP address, for example, the first network address, and the remaining three host address, so the mask is "11111111.00000000.00000000.00000000"

A Class Default Network Subnet Mask: 255.0.0.0
      Class B subnet mask, default network: 255.255.0.0
      Class C network default subnet mask: 255.255.255.0


2) Custom Subnet Mask : (for subnetting)

A network into several subnets, each subnet want to have a different network address or subnet address. Because IP is limited, in fact, we are the host address is divided into two parts: the network subnet address, subnet host address. Form as follows:

Without making subnetting ip address: the network address + host address
ip address do subnetting: + network address (subnet network address + subnet host address)

Four -, subnet mask and ip address

子网掩码是用来判断任意两台计算机的IP地址是否属于同一子网络的根据。具体说就是两台计算机各自的IP地址与子网掩码进行“与”运算后,如果得出的结果是相同的,则说明这两台计算机是处于同一个子网络上的,可以进行直接的通讯。


五、为什么要要划分子网?

例如:在A类IP地址中,每个A类网络可能有16,777,214台主机,它们处于同一广播域。在同一广播域中有这么多主机是不可能的,网络会因为广播通信而饱和。另一方面,IP地址资源越来越少。为实现更小的广播域,就需要进一步分成更小的网络。划分子网后,通过使用掩码,把子网隐藏起来,使得从外部看网络没有变化,这就是子网掩码。


六、子网划分简述

子网划分是通过借用IP地址中若干位主机地址来充当子网的网络地址,从而将原网络划分为若干子网。

划分子网时,随着子网地址借用主机位数的增多,子网的数目随之增加,但每个子网中的可用主机数逐渐减少。

如C类地址,原有8位主机位,2^8-2即254个主机地址,默认子网掩码255.255.255.0。(全0或全1不可用)
借用1位主机位,产生2^1-2=0个子网,每个子网有2^7个主机地址;
借用2位主机位,产生2^2-2=2个子网,每个子网有2^6个主机地址;
……


七、子网掩码计算

1、利用子网数来计算

在求子网掩码之前必须先搞清楚要划分的子网数目,以及每个子网内的所需主机数目。
1)将子网数目转化为二进制来表示
2)取得该二进制的位数,为 N
3)取得该 IP地址的类子网掩码,将其主机地址部分的的前N位置 1 即得出该IP地址划分子网的子网掩码。

如欲将C类IP地址192.168.10.0划分成4个子网:
1)4=100
2)该二进制为三位数,N = 3
3)将A类地址的子网掩码255.255.255.0的主机地址前3位置 1,得到子网掩码255.255.255.224。

2、利用主机数来计算

1)将主机数目转化为二进制来表示
2)如果主机数小于或等于254(注意去掉保留的两个IP地址),则取得该主机的二进制位数。
3)将该类IP地址的主机地址位数全部置1,然后从后向前的将N位全部置为 0,即为子网掩码值。

如欲将B类IP地址192.168.10.0划分成若干子网,每个子网内有主机25台:
1) 25=11001
2)该二进制为十位数,N = 5
3)将该B类地址的子网掩码 255.255.255.0的主机地址全部置 1,得到255.255.255.255,然后再从后向前将后5位置0,即为:11111111.11111111.11111111.11100000,即255.255.252.224。


Guess you like

Origin blog.51cto.com/14451009/2438448