What Is A Subnet Mask?

take 7 minutes to read
Home Points Main article

What is a subnet mask?

A subnet mask is a number used to calculate the IP composition.

An IP consists of 2 parts: Network Id and Host Id, and the subnet mask serves to distinguish these two parts.

Because IPv4 is a 32-bit number, the subnet mask is also a 32-bit number.

The subnet mask is a concept in IPv4 that no longer exists in IPv6.

web identity

Suppose, my host IP is 192.168.1.100, how do I determine if another IP 192.168.1.200 is on the same network segment as my host?

The same network segment

If you use the default subnet mask, which is 255.255.255.0, the IP and subnet mask by bit and arithmetic will give you the network identifier.

As follows, the network identifier of the first IP is

   192.168.001.100 
&   255.255.255.000 
-------------------- 
=   192.168.001.000

The network identifier for the second IP is.

   192.168.001.200 
&   255.255.255.000 
-------------------- 
=   192.168.001.000

Their network identifiers are the same, both are 192.168.1.0, so they are inside the same network segment.

Different network segments

In another case, if we use a mask of 255.255.255.192, then press the bitwise sum operation.

The network identifier for the first IP is.

   192.168.001.100 
&   255.255.255.192 
-------------------- 
=   192.168.001.64

The network identifier for the second IP is.

   192.168.001.200 
&   255.255.255.192 
-------------------- 
=   192.168.001.192

At this point they have different network identifiers, so they are no longer on the same network segment and cannot interoperate.

subnet assignment

Because we want to be able to isolate the hosts on the LAN by this mechanism.

Assuming our router uses network segment 192.168.1.0, there are probably a total of 200 or so computers connected to it.

Then, if we want them to be connected to each other, then just use the default mask and all IPs in the range 192.168.1.0-255 will be on a subnet and will all be connected to each other.

If we want to segregate them, for example, in a company where development, finance, marketing, and human resources each use their own IP segment, then we need to segment the IP, and here we can divide it into 4 segments:

  • Paragraph 1 development segment: 192.168.1.0 - 63
  • Segment 2 for finance: 192.168.1.64 - 127
  • Segment 3 for the market: 192.168.1.128 - 191
  • Para. 4 Manpower segment: 192.168.1.192 - 255

And how are subnet masks assigned?

The 192.168.1.0 segment has a total of 256 addresses, divided into 4 subnets, each with 64 IP addresses.

64 is the 6th power of 2, and the subnet mask should consist of 26 1s and 6 0s, converted to decimal as 255.255.255.192, which corresponds to binary as.

11111111.11111111.11111111.11000000

The IP address range of each department's computer is set, and the subnet mask must be set to 255.255.255.192, and the computers within each department can be networked normally after the settings are completed, and the computers between different departments cannot be connected directly.

Network segment and mask representation

We have divided 4 segments above, how can we represent these segments in a simple way?

Generally, the first address plus the mask bit is used to represent the entire IP segment, as follows.

  • Paragraph 1 development segment: 192.168.1.0 - 63, expressed as: 192.168.1.0/26
  • Segment 2 for finance: 192.168.1.64 - 127', expressed as 192.168.1.64/26'
  • Paragraph 3 market segment: 192.168.1.128 - 191, expressed as: 192.168.1.128/26
  • Para. 4 Human segment: 192.168.1.192 - 255, expressed as: 192.168.1.192/26

where 26 indicates the number of 1s in the mask, which is equivalent to the mask 255.255.255.192.

Note that the first and last addresses of each segment have special uses and are not available to users; the first address is the segment address, as in 192.168.1.0 above, and the last is the broadcast address, as in 192.168.1.63 above.

Single Core Improves By 15% And Multi-core Leads By 31%: The Metaphysical Performance Of AMD Ruilong 7000 Is A Hot Topic
« Prev 05-24
In China, Everyone Calls For Cash Loans: Run To Earn Money From Africans
Next » 05-24