如何计算"子网掩码"

2024-12-20 07:48:00
推荐回答(4个)
回答1:

1.子网掩码的概念

子网掩码是一个32位地址,用于屏蔽IP地址的一部分以区别网络标识和主机标识,并说明该IP地址是在局域网上,还是在远程网上。

2.确定子网掩码数

用于子网掩码的位数决定于可能的子网数目和每个子网的主机数目。在定义子网掩码前,必须弄清楚本来使用的子网数和主机数目。

定义子网掩码的步骤为:

A、确定哪些组地址归我们使用。比如我们申请到的网络号为 “210.73.a.b”,该网络地址为c类IP地址,网络标识为“210.73”,主机标识为“a.b”。

B、根据我们现在所需的子网数以及将来可能扩充到的子网数,用宿主机的一些位来定义子网掩码。比如我们现在需要12个子网,将来可能需要16个。用第三个字节的前四位确定子网掩码。前四位都置为“1”,即第三个字节为“11110000”,这个数我们暂且称作新的二进制子网掩码。

C、把对应初始网络的各个位都置为“1”,即前两个字节都置为“1”,第四个字节都置为“0”,则子网掩码的间断二进制形式为:“11111111.11111111.11110000.00000000”

D、把这个数转化为间断十进制形式为:“255.255.240.0”

这个数为该网络的子网掩码。

3.IP掩码的标注

A、无子网的标注法

对无子网的IP地址,可写成主机号为0的掩码。如IP地址210.73.140.5,掩码为255.255.255.0,也可以缺省掩码,只写IP地址。

B、有子网的标注法

有子网时,一定要二者配对出现。以C类地址为例。

1.IP地址中的前3个字节表示网络号,后一个字节既表明子网号,又说明主机号,还说明两个IP地址是否属于一个网段。如果属于同一网络区间,这两个地址间的信息交换就不通过路由器。如果不属同一网络区间,也就是子网号不同,两个地址的信息交换就要通过路由器进行。例如:对于IP地址为210.73.140.5的主机来说,其主机标识为00000101,对于IP地址为210.73.140.16的主机来说它的主机标识为00010000,以上两个主机标识的前面三位全是000,说明这两个IP地址在同一个网络区域中。

2.掩码的功用是说明有子网和有几个子网,但子网数只能表示为一个范围,不能确切讲具体几个子网,掩码不说明具体子网号,有子网的掩码格式(对C类地址):主机标识前几位为子网号,后面不写主机,全写0。

子网掩码 255。255。255。0
IP地址178.016.010.000
划分 218 个,子网掩码是255.255.255.0
每段子网的网络号是TO前IP的最后一位减1
每段子网的广播地址是TO后IP最后一位加1
1> 178.016.0.1 TO 178.016.0.254
2> 178.016.1.1 TO 178.016.1.254
3> 178.016.2.1 TO 178.016.2.254
4> 178.016.3.1 TO 178.016.3.254
5> 178.016.4.1 TO 178.016.4.254
6> 178.016.5.1 TO 178.016.5.254
7> 178.016.6.1 TO 178.016.6.254
8> 178.016.7.1 TO 178.016.7.254
9> 178.016.8.1 TO 178.016.8.254
10> 178.016.9.1 TO 178.016.9.254
11> 178.016.10.1 TO 178.016.10.254
12> 178.016.11.1 TO 178.016.11.254
13> 178.016.12.1 TO 178.016.12.254
14> 178.016.13.1 TO 178.016.13.254
15> 178.016.14.1 TO 178.016.14.254
16> 178.016.15.1 TO 178.016.15.254
17> 178.016.16.1 TO 178.016.16.254
18> 178.016.17.1 TO 178.016.17.254
19> 178.016.18.1 TO 178.016.18.254
20> 178.016.19.1 TO 178.016.19.254
21> 178.016.20.1 TO 178.016.20.254
22> 178.016.21.1 TO 178.016.21.254
23> 178.016.22.1 TO 178.016.22.254
24> 178.016.23.1 TO 178.016.23.254
25> 178.016.24.1 TO 178.016.24.254
26> 178.016.25.1 TO 178.016.25.254
27> 178.016.26.1 TO 178.016.26.254
28> 178.016.27.1 TO 178.016.27.254
29> 178.016.28.1 TO 178.016.28.254
30> 178.016.29.1 TO 178.016.29.254
31> 178.016.30.1 TO 178.016.30.254
32> 178.016.31.1 TO 178.016.31.254
33> 178.016.32.1 TO 178.016.32.254
34> 178.016.33.1 TO 178.016.33.254
35> 178.016.34.1 TO 178.016.34.254
36> 178.016.35.1 TO 178.016.35.254
37> 178.016.36.1 TO 178.016.36.254
38> 178.016.37.1 TO 178.016.37.254
39> 178.016.38.1 TO 178.016.38.254
40> 178.016.39.1 TO 178.016.39.254
41> 178.016.40.1 TO 178.016.40.254
42> 178.016.41.1 TO 178.016.41.254
43> 178.016.42.1 TO 178.016.42.254
44> 178.016.43.1 TO 178.016.43.254
45> 178.016.44.1 TO 178.016.44.254
46> 178.016.45.1 TO 178.016.45.254
47> 178.016.46.1 TO 178.016.46.254
48> 178.016.47.1 TO 178.016.47.254
49> 178.016.48.1 TO 178.016.48.254
50> 178.016.49.1 TO 178.016.49.254
51> 178.016.50.1 TO 178.016.50.254
52> 178.016.51.1 TO 178.016.51.254
53> 178.016.52.1 TO 178.016.52.254
54> 178.016.53.1 TO 178.016.53.254
55> 178.016.54.1 TO 178.016.54.254
56> 178.016.55.1 TO 178.016.55.254
57> 178.016.56.1 TO 178.016.56.254
58> 178.016.57.1 TO 178.016.57.254
59> 178.016.58.1 TO 178.016.58.254
60> 178.016.59.1 TO 178.016.59.254
61> 178.016.60.1 TO 178.016.60.254
62> 178.016.61.1 TO 178.016.61.254
63> 178.016.62.1 TO 178.016.62.254
64> 178.016.63.1 TO 178.016.63.254
65> 178.016.64.1 TO 178.016.64.254
66> 178.016.65.1 TO 178.016.65.254
67> 178.016.66.1 TO 178.016.66.254
68> 178.016.67.1 TO 178.016.67.254
69> 178.016.68.1 TO 178.016.68.254
70> 178.016.69.1 TO 178.016.69.254
71> 178.016.70.1 TO 178.016.70.254
72> 178.016.71.1 TO 178.016.71.254
73> 178.016.72.1 TO 178.016.72.254
74> 178.016.73.1 TO 178.016.73.254
75> 178.016.74.1 TO 178.016.74.254
76> 178.016.75.1 TO 178.016.75.254
77> 178.016.76.1 TO 178.016.76.254
78> 178.016.77.1 TO 178.016.77.254
79> 178.016.78.1 TO 178.016.78.254
80> 178.016.79.1 TO 178.016.79.254
81> 178.016.80.1 TO 178.016.80.254
82> 178.016.81.1 TO 178.016.81.254
83> 178.016.82.1 TO 178.016.82.254
84> 178.016.83.1 TO 178.016.83.254
85> 178.016.84.1 TO 178.016.84.254
86> 178.016.85.1 TO 178.016.85.254
87> 178.016.86.1 TO 178.016.86.254
88> 178.016.87.1 TO 178.016.87.254
89> 178.016.88.1 TO 178.016.88.254
90> 178.016.89.1 TO 178.016.89.254
91> 178.016.90.1 TO 178.016.90.254
92> 178.016.91.1 TO 178.016.91.254
93> 178.016.92.1 TO 178.016.92.254
94> 178.016.93.1 TO 178.016.93.254
95> 178.016.94.1 TO 178.016.94.254
96> 178.016.95.1 TO 178.016.95.254
97> 178.016.96.1 TO 178.016.96.254
98> 178.016.97.1 TO 178.016.97.254
99> 178.016.98.1 TO 178.016.98.254
100> 178.016.99.1 TO 178.016.99.254
101> 178.016.100.1 TO 178.016.100.254
102> 178.016.101.1 TO 178.016.101.254
103> 178.016.102.1 TO 178.016.102.254
104> 178.016.103.1 TO 178.016.103.254
105> 178.016.104.1 TO 178.016.104.254
106> 178.016.105.1 TO 178.016.105.254
107> 178.016.106.1 TO 178.016.106.254
108> 178.016.107.1 TO 178.016.107.254
109> 178.016.108.1 TO 178.016.108.254
110> 178.016.109.1 TO 178.016.109.254
111> 178.016.110.1 TO 178.016.110.254
112> 178.016.111.1 TO 178.016.111.254
113> 178.016.112.1 TO 178.016.112.254
114> 178.016.113.1 TO 178.016.113.254
115> 178.016.114.1 TO 178.016.114.254
116> 178.016.115.1 TO 178.016.115.254
117> 178.016.116.1 TO 178.016.116.254
118> 178.016.117.1 TO 178.016.117.254
119> 178.016.118.1 TO 178.016.118.254
120> 178.016.119.1 TO 178.016.119.254
121> 178.016.120.1 TO 178.016.120.254
122> 178.016.121.1 TO 178.016.121.254
123> 178.016.122.1 TO 178.016.122.254
124> 178.016.123.1 TO 178.016.123.254
125> 178.016.124.1 TO 178.016.124.254
126> 178.016.125.1 TO 178.016.125.254
127> 178.016.126.1 TO 178.016.126.254
128> 178.016.127.1 TO 178.016.127.254
129> 178.016.128.1 TO 178.016.128.254
130> 178.016.129.1 TO 178.016.129.254
131> 178.016.130.1 TO 178.016.130.254
132> 178.016.131.1 TO 178.016.131.254
133> 178.016.132.1 TO 178.016.132.254
134> 178.016.133.1 TO 178.016.133.254
135> 178.016.134.1 TO 178.016.134.254
136> 178.016.135.1 TO 178.016.135.254
137> 178.016.136.1 TO 178.016.136.254
138> 178.016.137.1 TO 178.016.137.254
139> 178.016.138.1 TO 178.016.138.254
140> 178.016.139.1 TO 178.016.139.254
141> 178.016.140.1 TO 178.016.140.254
142> 178.016.141.1 TO 178.016.141.254
143> 178.016.142.1 TO 178.016.142.254
144> 178.016.143.1 TO 178.016.143.254
145> 178.016.144.1 TO 178.016.144.254
146> 178.016.145.1 TO 178.016.145.254
147> 178.016.146.1 TO 178.016.146.254
148> 178.016.147.1 TO 178.016.147.254
149> 178.016.148.1 TO 178.016.148.254
150> 178.016.149.1 TO 178.016.149.254
151> 178.016.150.1 TO 178.016.150.254
152> 178.016.151.1 TO 178.016.151.254
153> 178.016.152.1 TO 178.016.152.254
154> 178.016.153.1 TO 178.016.153.254
155> 178.016.154.1 TO 178.016.154.254
156> 178.016.155.1 TO 178.016.155.254
157> 178.016.156.1 TO 178.016.156.254
158> 178.016.157.1 TO 178.016.157.254
159> 178.016.158.1 TO 178.016.158.254
160> 178.016.159.1 TO 178.016.159.254
161> 178.016.160.1 TO 178.016.160.254
162> 178.016.161.1 TO 178.016.161.254
163> 178.016.162.1 TO 178.016.162.254
164> 178.016.163.1 TO 178.016.163.254
165> 178.016.164.1 TO 178.016.164.254
166> 178.016.165.1 TO 178.016.165.254
167> 178.016.166.1 TO 178.016.166.254
168> 178.016.167.1 TO 178.016.167.254
169> 178.016.168.1 TO 178.016.168.254
170> 178.016.169.1 TO 178.016.169.254
171> 178.016.170.1 TO 178.016.170.254
172> 178.016.171.1 TO 178.016.171.254
173> 178.016.172.1 TO 178.016.172.254
174> 178.016.173.1 TO 178.016.173.254
175> 178.016.174.1 TO 178.016.174.254
176> 178.016.175.1 TO 178.016.175.254
177> 178.016.176.1 TO 178.016.176.254
178> 178.016.177.1 TO 178.016.177.254
179> 178.016.178.1 TO 178.016.178.254
180> 178.016.179.1 TO 178.016.179.254
181> 178.016.180.1 TO 178.016.180.254
182> 178.016.181.1 TO 178.016.181.254
183> 178.016.182.1 TO 178.016.182.254
184> 178.016.183.1 TO 178.016.183.254
185> 178.016.184.1 TO 178.016.184.254
186> 178.016.185.1 TO 178.016.185.254
187> 178.016.186.1 TO 178.016.186.254
188> 178.016.187.1 TO 178.016.187.254
189> 178.016.188.1 TO 178.016.188.254
190> 178.016.189.1 TO 178.016.189.254
191> 178.016.190.1 TO 178.016.190.254
192> 178.016.191.1 TO 178.016.191.254
193> 178.016.192.1 TO 178.016.192.254
194> 178.016.193.1 TO 178.016.193.254
195> 178.016.194.1 TO 178.016.194.254
196> 178.016.195.1 TO 178.016.195.254
197> 178.016.196.1 TO 178.016.196.254
198> 178.016.197.1 TO 178.016.197.254
199> 178.016.198.1 TO 178.016.198.254
200> 178.016.199.1 TO 178.016.199.254
201> 178.016.200.1 TO 178.016.200.254
202> 178.016.201.1 TO 178.016.201.254
203> 178.016.202.1 TO 178.016.202.254
204> 178.016.203.1 TO 178.016.203.254
205> 178.016.204.1 TO 178.016.204.254
206> 178.016.205.1 TO 178.016.205.254
207> 178.016.206.1 TO 178.016.206.254
208> 178.016.207.1 TO 178.016.207.254
209> 178.016.208.1 TO 178.016.208.254
210> 178.016.209.1 TO 178.016.209.254
211> 178.016.210.1 TO 178.016.210.254
212> 178.016.211.1 TO 178.016.211.254
213> 178.016.212.1 TO 178.016.212.254
214> 178.016.213.1 TO 178.016.213.254
215> 178.016.214.1 TO 178.016.214.254
216> 178.016.215.1 TO 178.016.215.254
217> 178.016.216.1 TO 178.016.216.254
218> 178.016.217.1 TO 178.016.217.254
219> 178.016.218.1 TO 178.016.218.254
220> 178.016.219.1 TO 178.016.219.254
221> 178.016.220.1 TO 178.016.220.254
222> 178.016.221.1 TO 178.016.221.254
223> 178.016.222.1 TO 178.016.222.254
224> 178.016.223.1 TO 178.016.223.254
225> 178.016.224.1 TO 178.016.224.254
226> 178.016.225.1 TO 178.016.225.254
227> 178.016.226.1 TO 178.016.226.254
228> 178.016.227.1 TO 178.016.227.254
229> 178.016.228.1 TO 178.016.228.254
230> 178.016.229.1 TO 178.016.229.254
231> 178.016.230.1 TO 178.016.230.254
232> 178.016.231.1 TO 178.016.231.254
233> 178.016.232.1 TO 178.016.232.254
234> 178.016.233.1 TO 178.016.233.254
235> 178.016.234.1 TO 178.016.234.254
236> 178.016.235.1 TO 178.016.235.254
237> 178.016.236.1 TO 178.016.236.254
238> 178.016.237.1 TO 178.016.237.254
239> 178.016.238.1 TO 178.016.238.254
240> 178.016.239.1 TO 178.016.239.254
241> 178.016.240.1 TO 178.016.240.254
242> 178.016.241.1 TO 178.016.241.254
243> 178.016.242.1 TO 178.016.242.254
244> 178.016.243.1 TO 178.016.243.254
245> 178.016.244.1 TO 178.016.244.254
246> 178.016.245.1 TO 178.016.245.254
247> 178.016.246.1 TO 178.016.246.254
248> 178.016.247.1 TO 178.016.247.254
249> 178.016.248.1 TO 178.016.248.254
250> 178.016.249.1 TO 178.016.249.254
251> 178.016.250.1 TO 178.016.250.254
252> 178.016.251.1 TO 178.016.251.254
253> 178.016.252.1 TO 178.016.252.254
254> 178.016.253.1 TO 178.016.253.254
255> 178.016.254.1 TO 178.016.254.254
256> 178.016.255.1 TO 178.016.255.254

回答2:

把十进制的ip和网关转成二进制,按位做逻辑与运算

回答3:

子网掩码和你的ip以及其它内网ip进行或计算必须得到相同的结果。
也就是说,你的ip和内网ip可以不同的二进制位对应掩码的二进制位必须为0,其它为1。

回答4:

IP和网关按位“与”运算