通过子网掩码计算IP范围 [英] Calculate IP range by subnet mask
问题描述
如果我有一个子网掩码例如 255.255.255.0
和IP地址 192.168.1.5
,有一个简单的方法来确定范围内的所有可能的IP地址?该子网
在这种情况下:
$ 192.168.1.1 b $ b 192.168.1.2
192.168.1.3
192.168.1.4
...
...
192.168.1.252
192.168.1.253
192.168.1.254
192.168.1.255
所有我发现到现在为止是沉重的过载。网库。是不是有与默认命名空间来解决这个任何本地方式
要确定ADRESS范围按以下步骤操作:<? / p>
1)把你的子网掩码(这里255.255.255.0),并将其转换为二进制:
11111111.11111111.11111111.00000000
(8 + 8 + 8 + 0 = 24 - >所以,你可以写你的ip住址是这样的:192.168.1.X / 24,因为你是在/ 24网络)
2)你有一个/ 24网络256-2 = 254可用IP不会忽略主机(一个是网络ADRESS(在你的范围内第一个),另一种是为广播ADRESS(在你的范围内的最后))。
3)为了让您只需范围内得到您的网络ADRESS(根据您的子网掩码的第一个IP地址),并获得下一个255的IP地址,你就会有你的范围。
的 您的网络地址:的
在二进制最后一个字节为空:
xxxxxxxx.xxxxxxxx.xxxxxxxx.00000000
的 您的广播地址:的
在二进制的最后一个字节必须等于1:
xxxxxxxx.xxxxxxxx.xxxxxxxx.11111111
下面的IP地址192.168.1.5是。
在二进制我们得到:
11000000.10101000.00000000.00000101
- 您的网络地址:11000000.10101000.00000000.00000000< - >
192.168.1.0 - 你的广播地址:11000000.10101000.000000000.11111111< - >
192.168.1.255 -
第一个可用的IP地址:192.168.1.1
-
最后一个可用IP地址:192.168.1.254
希望你喜欢阅读的英语不好。
告诉我,如果你有任何问题,
洛里斯
If I have a subnet mask e.g. 255.255.255.0
and an ip address 192.168.1.5
, is there an easy way to determine all the possible ip addresses within this subnet?
In this case:
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
...
...
192.168.1.252
192.168.1.253
192.168.1.254
192.168.1.255
All I found until now are heavy overloaded .net libraries. Isn't there any native way to solve this with the default namespaces?
To determine the adress range follow these steps :
1) Take your subnet mask (here 255.255.255.0) and convert it in binary :
11111111.11111111.11111111.00000000
( 8 + 8 + 8 + 0 = 24 -> So you can write your ip adresse like this : 192.168.1.x/24 because you are in a /24 network)
2) You have in a /24 network 256-2=254 usable ip adresses for host (one is for the network adress (the first in your range) and the other one is for the broadcast adress (the last in your range)).
3) To get your range simply get your network adress (the first ip adress according to your subnet mask) and get the next 255 ip addresses and you'll have your range.
Your network adress:
In binary the last octet has to be null :
xxxxxxxx.xxxxxxxx.xxxxxxxx.00000000
Your broadcast adress:
In binary the last octet has to be equal to 1:
xxxxxxxx.xxxxxxxx.xxxxxxxx.11111111
Here your ip adress is 192.168.1.5. In binary we get:
11000000.10101000.00000000.00000101
- Your network address: 11000000.10101000.00000000.00000000 <-> 192.168.1.0
- Your broadcast address: 11000000.10101000.000000000.11111111 <-> 192.168.1.255
First usable ip address: 192.168.1.1
Last usable ip address : 192.168.1.254
Hope you enjoyed reading bad english. Tell me if you have any question, Loris
这篇关于通过子网掩码计算IP范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!