codeblock

2016年3月9日 星期三

IP address, Subnet, Netmask

- Classes of IP address:

- There are also class D and E, and the leading bits are 1110 and 1111 respectively.
- IP address is divided into two parts, net id and host id.
- Hosts with the same net id are within the same subnet.



For example, a common notation of a subnet looks like "192.168.0.0/24". It means the first 24 bits of a IP address in this subnet are net id, and the rest 8 bits are host id. In this example, there are 2^8 = 256 IP addresses could be used in this subnet, where 192.168.0.0 is reserved for the recognition of the subnet(all bits of host id are 0), and 192.168.0.255 is reserved for broadcast address(all bits of host id  are 1). Therefore, up to 254 hosts are allowed in this subnet, from 192.168.0.1 to 192.168.0.254.

- Netmask address is a IP address the bits of  net id part are all 1 and the host id part are all 0.

Netmask address of class A IP addresses is 255.0.0.0, the one of class B IP addresses is 255.255.0.0, and the one of  "192.168.0.0/24" (also class C) is 255.255.255.0. Note that the number "24" in the notation also equals to the number of bit 1 in the netmask address.

- We can divide a network into many small subnets by extending the net id part of address.

Consider extending the net id of "192.168.0.0/24" 1 bit to make it totally 25 bits, which is 24 network prefix adds 1 subnet number. The subnet mask is 255.255.255.128 and the whole network has two subnets, 192.168.0.0/25 and 192.168.0.128/25. In both of two subnets, up to 2^7 -2 = 126 hosts are allowed (192.168.0.1~192.168.0.126 and 192.168.0.129~192.168.0.254).

- Some IP addresses are reserved for private network.


See also:
 - https://support.microsoft.com/zh-tw/kb/164015
 - https://en.wikipedia.org/wiki/IP_address
 - https://en.wikipedia.org/wiki/Subnetwork
 - http://jodies.de/ipcalc


沒有留言:

張貼留言